Delete File and Send it to RecycleBin

When we use File.Delete(path);

It automatically delete file .

It cannot be recover.

 

It never go in Recycle Bin.

 

So delete operation must be done with care.

 

 

So here is a code which delete file and send to recycle bin.

 

 

First add reference Microsoft.VisualBasic

 

And use the following code to delete file:

 

 

using Microsoft.VisualBasic;

 

 

   string path = @"C:\1.txt";

            Microsoft.VisualBasic.FileIO.FileSystem.DeleteFile(path,Microsoft.VisualBasic.FileIO.UIOption.AllDialogs,Microsoft.VisualBasic.FileIO.RecycleOption.SendToRecycleBin,Microsoft.VisualBasic.FileIO.UICancelOption.DoNothing);

 

 

 

 

 

 

Next Recommended Reading Convert Powerpoint file into Image file