Beispiel #1
0
        /// <summary>
        /// Background process form restoring data
        /// </summary>
        /// <param name="state">File name to get data</param>
        private static void Restore(object state)
        {
            string unzip = @"unzip\unzip.exe";

            unzip = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), unzip);
            string file = (string)state;

            //delete old
            string path = LocalDirectory.DefaultPath;

            SHOperations.Delete(new string[] { path },
                                SHOperations.FileOperationFlags.FOF_ALLOWUNDO |
                                SHOperations.FileOperationFlags.FOF_NOCONFIRMATION |
                                SHOperations.FileOperationFlags.FOF_SIMPLEPROGRESS);

            while (System.IO.Directory.Exists(path))
            {
                System.Threading.Thread.Sleep(100);
            }

            //restore all
            string arg = string.Format("-o -d \"{0}\" \"{1}\"", path, file);

            System.Diagnostics.Process.Start(unzip, arg).WaitForExit();

            //restore registry
            string regfile = Path.Combine(path, "backup.reg");

            RestorRegistryData(regfile);

            //prompt to restart application
            string msg = "Data restore finished. You need to restart the application to make some settings effective.";

            if (MessageBox.Show(msg, Application.ProductName, MessageBoxButtons.OKCancel) == DialogResult.Cancel)
            {
                return;
            }
            Application.Restart();
        }
Beispiel #2
0
 /// <summary>
 /// Send files and folders to recycle-bin
 /// </summary>
 /// <param name="files">List of files and folders to delete</param>
 public static void DeleteFilesOrFolders(string[] files)
 {
     SHOperations.SendToRecycleBin(files);
 }
Beispiel #3
0
 /// <summary>
 /// Move files and folders to the destination directory
 /// </summary>
 /// <param name="from">List of files and folders to copy</param>
 /// <param name="dest">Destination folder for the given files and folders</param>
 public static void MoveFilesOrFolders(string[] from, string dest)
 {
     SHOperations.Move(from, dest);
 }
Beispiel #4
0
 /// <summary>
 /// Change the name of a file or folder
 /// </summary>
 /// <param name="from">Current path of file or folder</param>
 /// <param name="dest">Destination name</param>
 public static void RenameFileOrFolder(string from, string dest)
 {
     SHOperations.Rename(from, dest);
 }
Beispiel #5
0
 //
 // SH-File-Operation
 //
 /// <summary>
 /// Copy files and folders to the destination directory
 /// </summary>
 /// <param name="from">List of files and folders to copy</param>
 /// <param name="dest">Destination folder for the given files and folders</param>
 public static void CopyFilesOrFolders(string[] from, string dest)
 {
     SHOperations.Copy(from, dest);
 }