Net Encryption Library
SecureDirectoryErase(String,String) Method
Example 






KellermanSoftware.NetEncryptionLibrary Namespace > Encryption Class > SecureDirectoryErase Method : SecureDirectoryErase(String,String) Method
The directory to erase
File wildcard pattern
Securely erase files within a directory and sub directories according to the search pattern. The algorithm used to overwrite files is Random
Syntax
'Declaration
 
Public Overloads Sub SecureDirectoryErase( _
   ByVal directoryPath As System.String, _
   ByVal searchPattern As System.String _
) 
'Usage
 
Dim instance As Encryption
Dim directoryPath As System.String
Dim searchPattern As System.String
 
instance.SecureDirectoryErase(directoryPath, searchPattern)
public void SecureDirectoryErase( 
   System.string directoryPath,
   System.string searchPattern
)
public procedure SecureDirectoryErase( 
    directoryPath: System.String;
    searchPattern: System.String
); 
public function SecureDirectoryErase( 
   directoryPath : System.String,
   searchPattern : System.String
);
public: void SecureDirectoryErase( 
   System.string* directoryPath,
   System.string* searchPattern
) 
public:
void SecureDirectoryErase( 
   System.String^ directoryPath,
   System.String^ searchPattern
) 

Parameters

directoryPath
The directory to erase
searchPattern
File wildcard pattern
Example
Encryption encryption = new Encryption(); //Trial Mode
//Encryption encryption = new Encryption("place user name here", "place license key here"); //License Mode
 
string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "TestDirectory");
Directory.CreateDirectory(path);
 
string testFile = Path.Combine(path, "testfile.txt");
File.WriteAllText(testFile, "This is a test");
 
string nonMatchingFile = Path.Combine(path, "testfile.log");
File.WriteAllText(nonMatchingFile, "This is a test");
 
encryption.SecureDirectoryErase(path, "*.txt");
 
bool fileExists = File.Exists(testFile);
Console.WriteLine("Matching File Exists: {0}", fileExists);
 
fileExists = File.Exists(nonMatchingFile);
Console.WriteLine("Non Matching File Exists: {0}", fileExists);
Dim encryption As New Encryption() 'Trial Mode
'Dim encryption As New Encryption("place user name here", "place license key here") 'License Mode
 
Dim path As String = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "TestDirectory")
Directory.CreateDirectory(path)
 
Dim testFile As String = Path.Combine(path, "testfile.txt")
File.WriteAllText(testFile, "This is a test")
 
Dim nonMatchingFile As String = Path.Combine(path, "testfile.log")
File.WriteAllText(nonMatchingFile, "This is a test")
 
encryption.SecureDirectoryErase(path, "*.txt")
 
Dim fileExists As Boolean = File.Exists(testFile)
Console.WriteLine("Matching File Exists: {0}", fileExists)
 
fileExists = File.Exists(nonMatchingFile)
Console.WriteLine("Non Matching 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