Is it possible to create a folder from vb?
When the user enters a folder name it must give the message
"does not exist and create one?"
Printable View
Is it possible to create a folder from vb?
When the user enters a folder name it must give the message
"does not exist and create one?"
Hello ajitha again,
a Folder is a directory. To make a directory use:
MkDir("c:\YourDirectory")
Also handy: ChDir, CurDir & RmDir.
Nice regards,
Michelle.
Here is a real basic way...
Code:Dim MyDir As String
MyDir = "C:\GARBAGE"
If Dir(MyDir, vbDirectory) = "" Then
If MsgBox(MyDir & " don't exist, create?", vbYesNo + vbQuestion) = vbYes Then MkDir MyDir
Else
MsgBox MyDir & " already exists!", vbInformation
End If
Don't know why, but this is said to be a better and faster way to check if a folder/file exists or not.
Code:Dim MyDir As String
MyDir = "C:\MyFolder"
If Len(Dir(MyDir, vbDirectory)) = 0 Then
If MsgBox(MyDir & " don't exist, create?", vbYesNo + vbQuestion) = vbYes Then MkDir MyDir
Else
MsgBox MyDir & " already exists!", vbInformation
End If
Well Matt, string comparation is slower than returning the size of a string :) Altough you wont win a **** by displaying a msgbox right after heh :p. Using Cbool() instead of comparing with 0 would be even faster though, you may win a nanosecond hehe
[Edited by kedaman on 01-10-2001 at 08:14 AM]