public void ButtonBackupDictionary()
 {
     if (BackupDictionary())
     {
         DebugUtils.LogSuccess(this, "Successfully backuped dictionary.");
     }
     else
     {
         DebugUtils.LogWarning(this, "Could not backup dictionary.");
     }
 }
Example #2
0
 public static bool WriteToFile(string path, string content, bool needLogs = false, bool createFile = true)
 {
     if (File.Exists(path) || createFile)
     {
         System.IO.File.WriteAllText(path, content);
         if (needLogs)
         {
             DebugUtils.LogSuccess(null, "FileUtils.WriteToFile: successfully wrote file " + DebugUtils.ToQuote(path) + ".");
         }
         return(true);
     }
     else if (createFile)
     {
         DebugUtils.LogError(null, "FileUtils.WriteToFile: File " + DebugUtils.ToQuote(path) + " does not exists.");
     }
     return(false);
 }
Example #3
0
 public static bool DeleteFile(string path, bool needLogs = false)
 {
     if (File.Exists(path))
     {
         File.Delete(path);
         File.Delete(path + ".meta");
         if (needLogs)
         {
             DebugUtils.LogSuccess(null, "FileUtils.DeleteFile: successfully deleted file " + DebugUtils.ToQuote(path) + ".");
         }
         return(true);
     }
     else if (needLogs)
     {
         DebugUtils.LogWarning(null, "FileUtils.DeleteFile: File " + DebugUtils.ToQuote(path) + " does not exists.");
     }
     return(false);
 }
Example #4
0
        public static bool DeleteFolder(string path, bool recursive = true, bool needLogs = false)
        {
            bool success = true;

            try
            {
                Directory.Delete(path, recursive);
                if (needLogs)
                {
                    DebugUtils.LogSuccess(null, "FileUtils.DeleteFolder: successfully deleted folder " + DebugUtils.ToQuote(path));
                }
            }
            catch
            {
                success = false;
                if (needLogs)
                {
                    DebugUtils.LogError(null, "FileUtils.DeleteFolder: Could not delete folder " + DebugUtils.ToQuote(path));
                }
            }
            return(success);
        }
Example #5
0
        public static bool CreateFolder(string path, bool needLogs = false)
        {
            bool success = true;

            try
            {
                Directory.CreateDirectory(path);
                if (needLogs)
                {
                    DebugUtils.LogSuccess(null, "FileUtils.CreateFolder: successfully created folder " + DebugUtils.ToQuote(path));
                }
            }
            catch
            {
                success = false;
                if (needLogs)
                {
                    DebugUtils.LogError(null, "FileUtils.CreateFolder: Could not create folder " + DebugUtils.ToQuote(path));
                }
            }
            return(success);
        }
Example #6
0
        public static bool CopyFile(string fromPath, string toPath, bool needLogs = false)
        {
            bool success = true;

            try
            {
                File.Copy(fromPath, toPath);
                if (needLogs)
                {
                    DebugUtils.LogSuccess(null, "FileUtils.CopyFile: Successfully copied file " + DebugUtils.ToQuote(fromPath) + " to " + DebugUtils.ToQuote(toPath));
                }
            }
            catch
            {
                success = false;
                if (needLogs)
                {
                    DebugUtils.LogError(null, "FileUtils.CopyFile: Could not copy file " + DebugUtils.ToQuote(fromPath) + " to " + DebugUtils.ToQuote(toPath));
                }
            }
            return(success);
        }