Alex Rivera | Logout

How do I create a folder in VB if it doesn't exist?

Asked 2008-09-17T18:10:25.570
70

I wrote myself a little downloading application so that I could easily grab a set of files from my server and put them all onto a new pc with a clean install of Windows, without actually going on the net. Unfortunately I'm having problems creating the folder I want to put them in and am unsure how to go about it.

I want my program to download the apps to program files\any name here\

So basically I need a function that checks if a folder exists, and if it doesn't it creates it.

Edit
Report

2 Answers

197
If Not System.IO.Directory.Exists(YourPath) Then
    System.IO.Directory.CreateDirectory(YourPath)
End If
answered 2008-09-17T18:12:41.243
1

You should try using the File System Object or FSO. There are many methods belonging to this object that check if folders exist as well as creating new folders.

answered 2008-09-17T18:13:58.730

Your Answer