Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delete Folders and Containing Files

I have a really quick question. My program actually downloads a zip file then extracts it onto their desktop. But I need an uninstall feature for it, which is basically deleting multiple folders and containing files. How can I do this in vb.net?

like image 850
lab12 Avatar asked Feb 11 '10 01:02

lab12


1 Answers

If all of your folders are contained in a single folder, it should be pretty straight forward.

Dim path As String = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) & "\YOURPATH"
System.IO.Directory.Delete(path, True)

That will delete your root directory, and all the directories and files below it. You could just call this several times over if your files and directories are not all in a single root directory like "YOURPATH" in the example. This will spare you from having to remove each file individually.

like image 180
Steve Danner Avatar answered Sep 18 '22 07:09

Steve Danner