Example #1
0
 public static void CopyFolder(NPath fromPath, NPath toPath)
 {
     Logger.Trace("CopyFolder from {0} to {1}", fromPath, toPath);
     toPath.DeleteIfExists();
     toPath.EnsureParentDirectoryExists();
     fromPath.Move(toPath);
 }
Example #2
0
        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);
        }
Example #3
0
        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();
            }
        }