public static void CopyFolder(NPath fromPath, NPath toPath) { Logger.Trace("CopyFolder from {0} to {1}", fromPath, toPath); toPath.DeleteIfExists(); toPath.EnsureParentDirectoryExists(); fromPath.Move(toPath); }
public UsageStore Load(string userId) { UsageStore result = null; string json = null; if (path.FileExists()) { try { json = path.ReadAllText(Encoding.UTF8); result = json?.FromJson <UsageStore>(lowerCase: true); } catch (Exception ex) { LogHelper.Instance.Warning(ex, "Error Loading Usage: {0}; Deleting File", path); try { path.DeleteIfExists(); } catch { } } } if (result == null) { result = new UsageStore(); } if (String.IsNullOrEmpty(result.Model.Guid)) { result.Model.Guid = userId; } return(result); }
public static void Copy(NPath fromPath, NPath toPath) { Logger.Trace("Copying from {0} to {1}", fromPath, toPath); try { CopyFolder(fromPath, toPath); } catch (Exception ex1) { Logger.Warning(ex1, "Error copying."); try { CopyFolderContents(fromPath, toPath); } catch (Exception ex2) { Logger.Error(ex2, "Error copying contents."); throw; } } finally { fromPath.DeleteIfExists(); } }