Delete all file in directory vb.net




















Deleting the Directory its files and Child Directories. The below function will delete the Root Directory and also its files, Child Directories and their files too using recursion. DeleteDirectory path ;. Exists path. GetFiles path. Delete file ;. GetDirectories path. DeleteDirectory directory ;. Delete path ;. DeleteDirectory path. End Sub. If Directory. Learn more. Asked 11 years, 11 months ago. Active 5 years, 4 months ago. Viewed 79k times. Improve this question. Add a comment. Active Oldest Votes.

If all of your folders are contained in a single folder, it should be pretty straight forward. GetFolderPath Environment. Delete path, True That will delete your root directory, and all the directories and files below it. Improve this answer. Steve Danner Steve Danner This answer is better than mine.

GetFiles path File. Delete path End If End Sub. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Stack Gives Back Read this note there : Use the My. It depends on you how you want to input path. Your options are : Using a FolderBrowserDialog.

Selectedpath End if Now path variable holds user selected path. Put it as argument for GetFiles If you want to hardcode path. Thanks "Feel the Force! Dim fb as new As New System. FolderBrowserDialog If fb. Smith 0. I do that often with temp folders that I create: If My. CreateDirectory tempZipFolder. Although I'm confused how that comment is related to code in question.



0コメント

  • 1000 / 1000