Example #1
0
        public static void CheckWatchedFolders(this FileSystemState fileSystemState, ProgressContext progress)
        {
            if (fileSystemState == null)
            {
                throw new ArgumentNullException("fileSystemState");
            }
            AesKey encryptionKey = fileSystemState.KnownKeys.DefaultEncryptionKey;

            if (encryptionKey == null)
            {
                return;
            }
            IEnumerable <IRuntimeFileInfo> files = fileSystemState.DecryptedFilesInWatchedFolders();

            progress.NotifyLevelStart();
            try
            {
                progress.AddTotal(files.Count());
                foreach (IRuntimeFileInfo fileInfo in files)
                {
                    IRuntimeFileInfo destinationFileInfo = fileInfo.CreateEncryptedName();
                    AxCryptFile.EncryptFileWithBackupAndWipe(fileInfo, destinationFileInfo, encryptionKey, progress);
                    progress.AddCount(1);
                }
            }
            finally
            {
                progress.NotifyLevelFinished();
            }
        }