Ejemplo n.º 1
0
        public static long?GetFolderSizeRecursive(DirectoryInfo startDirectory, KlerksSoft.EasyProgressDialog.ProgressDialog progressDialog)
        {
            if (progressDialog != null && !progressDialog.Worker_IncrementProgress())
            {
                return(null);
            }
            long?fileSizes = 0;

            foreach (FileInfo nextFile in startDirectory.GetFiles())
            {
                fileSizes += nextFile.Length;
            }
            foreach (DirectoryInfo nextDirectory in startDirectory.GetDirectories())
            {
                fileSizes += GetFolderSizeRecursive(nextDirectory, progressDialog);
            }
            return(fileSizes);
        }
Ejemplo n.º 2
0
        private void bg_RestoreFilesToDestination_DoWork(object WorkArg)
        {
            KeyValuePair <string, Dictionary <string, string> > args = (KeyValuePair <string, Dictionary <string, string> >)WorkArg;
            string destinationPath = args.Key;
            Dictionary <string, string> restoreList = args.Value;

            foreach (string restoreFile in restoreList.Keys)
            {
                if (restoreFile.EndsWith(".encrypted"))
                {
                    Utils.DecryptFile(restoreFile, Path.Combine(destinationPath, restoreList[restoreFile]), _password);
                }
                else
                {
                    File.Copy(restoreFile, Path.Combine(destinationPath, restoreList[restoreFile]));
                }

                if (_progressDialog != null && !_progressDialog.Worker_IncrementProgress())
                {
                    return;
                }
            }
        }