示例#1
0
        internal static void EncryptDecryptDirectoryInternal(string path, bool encrypt, bool recursive, PathFormat pathFormat)
        {
            string pathLp = Path.GetExtendedLengthPathInternal(null, path, pathFormat, GetFullPathOptions.RemoveTrailingDirectorySeparator | GetFullPathOptions.FullCheck);

            var options = DirectoryEnumerationOptions.FilesAndFolders | DirectoryEnumerationOptions.AsLongPath;

            // Process folders and files when recursive.
            if (recursive)
            {
                options |= DirectoryEnumerationOptions.Recursive;

                foreach (string fso in EnumerateFileSystemEntryInfosInternal <string>(null, pathLp, Path.WildcardStarMatchAll, options, PathFormat.LongFullPath))
                {
                    File.EncryptDecryptFileInternal(true, fso, encrypt, PathFormat.LongFullPath);
                }
            }

            // Process the root folder, the given path.
            File.EncryptDecryptFileInternal(true, pathLp, encrypt, PathFormat.LongFullPath);
        }
 public void Decrypt()
 {
     File.EncryptDecryptFileInternal(false, LongFullName, false, PathFormat.LongFullPath);
 }