Net Encryption Library
SecureFileErase(String,SecureEraseAlgorithm) Method
Example 






KellermanSoftware.NetEncryptionLibrary Namespace > Encryption Class > SecureFileErase Method : SecureFileErase(String,SecureEraseAlgorithm) Method
The full path to the file
The algorithm to overwite with
Securely delete a file by overwriting with the passed in algorithm, then renaming, then deleting it
Syntax
'Declaration
 
Public Overloads Sub SecureFileErase( _
   ByVal filePath As System.String, _
   ByVal algorithm As SecureEraseAlgorithm _
) 
'Usage
 
Dim instance As Encryption
Dim filePath As System.String
Dim algorithm As SecureEraseAlgorithm
 
instance.SecureFileErase(filePath, algorithm)
public void SecureFileErase( 
   System.string filePath,
   SecureEraseAlgorithm algorithm
)
public procedure SecureFileErase( 
    filePath: System.String;
    algorithm: SecureEraseAlgorithm
); 
public function SecureFileErase( 
   filePath : System.String,
   algorithm : SecureEraseAlgorithm
);
public: void SecureFileErase( 
   System.string* filePath,
   SecureEraseAlgorithm algorithm
) 
public:
void SecureFileErase( 
   System.String^ filePath,
   SecureEraseAlgorithm algorithm
) 

Parameters

filePath
The full path to the file
algorithm
The algorithm to overwite with
Example
Encryption encryption = new Encryption(); //Trial Mode
//Encryption encryption = new Encryption("place user name here", "place license key here"); //License Mode
 
string testFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "testfile.txt");
File.WriteAllText(testFile, "This is a test");
 
Stopwatch watch = new Stopwatch();
watch.Start();
encryption.SecureFileErase(testFile, SecureEraseAlgorithm.Dod7);
watch.Stop();
Console.WriteLine("Elapsed: " + watch.ElapsedMilliseconds);
 
bool fileExists = File.Exists(testFile);
Console.WriteLine("File Exists: {0}", fileExists);
Dim encryption As New Encryption() 'Trial Mode
'Encryption encryption = new Encryption("place user name here", "place license key here"); //License Mode
 
Dim testFile As String = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "testfile.txt")
File.WriteAllText(testFile, "This is a test")
 
Dim watch As New Stopwatch()
watch.Start()
encryption.SecureFileErase(testFile, SecureEraseAlgorithm.Dod7)
watch.Stop()
Console.WriteLine("Elapsed: " & watch.ElapsedMilliseconds)
 
Dim fileExists As Boolean = File.Exists(testFile)
Console.WriteLine("File Exists: {0}", fileExists)
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

Encryption Class
Encryption Members
Overload List