示例#1
0
        internal static void EncryptDecryptDirectoryCore(string path, bool encrypt, bool recursive, PathFormat pathFormat)
        {
            string pathLp = Path.GetExtendedLengthPathCore(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 fsei in EnumerateFileSystemEntryInfosCore <string>(null, pathLp, Path.WildcardStarMatchAll, options, PathFormat.LongFullPath))
                {
                    File.EncryptDecryptFileCore(true, fsei, encrypt, PathFormat.LongFullPath);
                }
            }

            // Process the root folder, the given path.
            File.EncryptDecryptFileCore(true, pathLp, encrypt, PathFormat.LongFullPath);
        }
示例#2
0
        internal static void EncryptDecryptDirectoryCore(string path, bool encrypt, bool recursive, PathFormat pathFormat)
        {
            if (pathFormat != PathFormat.LongFullPath)
            {
                path = Path.GetExtendedLengthPathCore(null, path, pathFormat, GetFullPathOptions.RemoveTrailingDirectorySeparator | GetFullPathOptions.FullCheck);

                pathFormat = PathFormat.LongFullPath;
            }


            // Process folders and files when recursive.
            if (recursive)
            {
                foreach (var fsei in EnumerateFileSystemEntryInfosCore <string>(null, null, path, Path.WildcardStarMatchAll, SearchOption.AllDirectories, DirectoryEnumerationOptions.AsLongPath, null, pathFormat))
                {
                    File.EncryptDecryptFileCore(true, fsei, encrypt, pathFormat);
                }
            }

            // Process the root folder, the given path.
            File.EncryptDecryptFileCore(true, path, encrypt, pathFormat);
        }
示例#3
0
 public void Decrypt()
 {
     File.EncryptDecryptFileCore(false, LongFullName, false, PathFormat.LongFullPath);
 }