GetTempFileName() public static method

Copy the selected file to a temporary file name this function is used mostly for restore of corrupted data, so that the corrupted version of file can be stored in /tmp for debugging
public static GetTempFileName ( string file ) : bool
file string /// File ///
return bool
Example #1
0
 /// <summary>
 /// Recover a file that was previously stored
 /// </summary>
 /// <param name="name"></param>
 /// <param name="ch"></param>
 /// <returns></returns>
 public static bool RecoverFile(string name, string ch = "unknown object")
 {
     try
     {
         if (File.Exists(Configuration.TempName(name)))
         {
             if (Core.GetTempFileName(name))
             {
                 Syslog.Log("Restoring unfinished transaction of " + ch + " for db_" + name);
                 File.Copy(Configuration.TempName(name), name, true);
                 return(true);
             }
             Syslog.Log("Unfinished transaction could not be restored! DB of " + name + " is probably broken", true);
         }
         return(false);
     }
     catch (Exception b)
     {
         HandleException(b);
         Syslog.Log("Unfinished transaction could not be restored! DB of " + name + " is now broken");
         return(false);
     }
 }