Single Statement for Removal of Folders and SubFolders

Posted by VIJI Saturday, July 4, 2009

To Remove Folders and Sub Folders, a simple statement is enough.



Private Sub RemoveDirectory(ByVal sDirPath As String)

'True indicates the removal of sub folders as well
System.IO.Directory.Delete(sDirPath, True)


End Sub







Private Sub RemoveDirectory(ByVal sDirPath As String)

my.Computer.FileSystem.DeleteDirectory(sDirPath,FileIO.DeleteDirectoryOption.DeleteAllContents)

End Sub



Both the above statements will remove the folders and sub folders.


Example:

RemoveDirectory("C:\Temp")

will remove the folder Temp and its Sub Folders.

0 Responses to Single Statement for Removal of Folders and SubFolders

Post a Comment