示例#1
0
        public void SecureFile_WipeAndDelete()
        {
            // Verify that a file can be wiped and deleted.  Note that there's
            // no reasonable way to automate a check to see that the file
            // was actually wiped.  It's best to step through the code manually
            // to verify this.

            var path = Path.GetTempFileName();

            using (var fs = new FileStream(path, FileMode.Create, FileAccess.ReadWrite))
            {
                for (int i = 0; i < 1000000; i++)
                {
                    fs.WriteByte((byte)i);
                }
            }

            SecureFile.WipeAndDelete(path, 3);
            Assert.IsFalse(System.IO.File.Exists(path));

            // Verify that calling WipeAndDelete() on a non-existant file
            // does not throw an exception.

            SecureFile.WipeAndDelete(path, 3);
        }