I am using VS 2008, .net 3.5, C # projects. I need to do the same as Microsoft.VisualBasic.FileIO.FileSystem.DeleteDirectory.
Anyone says that linking to Microsoft.VisualBasic is often undesirable from C #. Any connection to VB from C # code amazes me as junk.
Using the FileSystem class is the perfect solution, but I prefer not to reference the Microsoft.VisualBasic library. That I would avoid.
private static void DeleteDirectory(string destino)
{
Microsoft.VisualBasic.FileIO.FileSystem.DeleteDirectory(destino,
Microsoft.VisualBasic.FileIO.UIOption.OnlyErrorDialogs,
Microsoft.VisualBasic.FileIO.RecycleOption.DeletePermanently,
Microsoft.VisualBasic.FileIO.UICancelOption.ThrowException);
}
Other samples:
How to place a file in the trash instead of deleting it?
Microsoft.VisualBasic.FileIO.FileSystem.DeleteFile(file.FullName,
Microsoft.VisualBasic.FileIO.UIOption.OnlyErrorDialogs,
Microsoft.VisualBasic.FileIO.RecycleOption.SendToRecycleBin);
source
share