Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a Directory in Windows

Status
Not open for further replies.

speltrain

Technical User
Apr 29, 2003
17
0
0
US
Is there a simple way to create a directory using Visual Basic? I simply want to create the directory c:\Batch Files\.
 
Thanks, I figured it right after I sent the post. sorry for taking up space
 
Be sure to test that it's not already there first...

Error trapping or Dir() being the easier methods...

mmilan
 
You could also use this, it allows you to make as long a directory poath as you like.

Code:
Private Declare Function SHCreateDirectoryEx Lib "shell32" Alias _
    "SHCreateDirectoryExA" (ByVal hwnd As Long, ByVal pszPath As String, _
    ByVal psa As Any) As Long
Private Sub Form_Load()
    'KPD-Team 2000
    'URL: [URL unfurl="true"]http://www.allapi.net/[/URL]
    'E-Mail: KPDTeam@allapi.net
    'create the directory 'c:\test\dir\hello\something\apiguide\'
    SHCreateDirectoryEx Me.hwnd, "c:\test\dir\hello\something\apiguide\", _
        ByVal 0&
End Sub

Hope this helps!!!
 
What would an example of using the Dir() function look like?
 
if dir("c:\My Test Folder",vbdirectory)<>"" then msgbox "folder exists
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top