create a folder useing vb code?

T

Tips

In VB 2005 using

My.Computer.FileSystem.CreateDirectory ("C:\MYDIR")


In VB.NET
Imports System
Imports System.IO

Dim di As DirectoryInfo = New DirectoryInfo("c:\MyDir")
' Determine whether the directory exists.
If di.Exists Then
' Indicate that it already exists.
msgbox("That path exists already.")
Else
' Try to create the directory.
di.Create()
End If
 
C

Cyril Gupta

Hello Tips,

There's another method that removes the need of declaring a variable.

System.IO.Directory.CreateDirectory("C:\MyDirectory")

This single line will serve your purpose well.

Regards
Cyril Gupta

You can do anything with a little bit of 'magination.
I have been programming so long, that my brain is now soft-ware.
http://www.cyrilgupta.com/blog
 
T

Tips

Hello Cyril,

Thanks, But i'v declared the "di" variable just to determine whether
the directory exists.

Regards
Elnahrawi
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top