示例#1
0
        public void TestDecrypt()
        {
            var tempLongPathFilename = new StringBuilder(uncDirectory).Append(@"\").Append("filename.ext").ToString();

            try {
                using (var s = Pri.LongPath.File.Create(tempLongPathFilename, 200)) { }

                var preAttrib = Pri.LongPath.File.GetAttributes(tempLongPathFilename);
                Assert.AreEqual(( FileAttributes )0, preAttrib & FileAttributes.Encrypted);

                var fi = new FileInfo(tempLongPathFilename);
                fi.Encrypt();

                var postAttrib = Pri.LongPath.File.GetAttributes(tempLongPathFilename);
                Assert.AreEqual(FileAttributes.Encrypted, postAttrib & FileAttributes.Encrypted);

                fi.Decrypt();

                postAttrib = Pri.LongPath.File.GetAttributes(tempLongPathFilename);
                Assert.AreEqual(( FileAttributes )0, postAttrib & FileAttributes.Encrypted);
            }
            finally {
                Pri.LongPath.File.Delete(tempLongPathFilename);
            }
        }