I have been able to delete files permanently with below code:
var DeleteFromDir = new DirectoryInfo(sFromPath);
var files = DeleteFromDir.GetFiles(".txt");
foreach(var file in files)
{
if(bDeletePermanently)
file.Delete();
else
; //Move to recycle bin
}
I tried below :
Add a reference to Microsoft.VisualBasic assembly. The needed class is found in this library.
Add this using statement to the top of the file using Microsoft.VisualBasic.FileIO;
Use FileSystem.DeleteFile to delete a file, it has the option to specify recycle bin or not.
But this works only with UI context and my application is Console based.