5 replies
by juanja
Try to access de file System Object by using this method:
Private Sub Command1_Click()
' Get instance of FileSystemObject.
Set fso = CreateObject("Scripting.FileSystemObject")
This method works for vbcript and Visual Basic.
Then, proceed tocreate the folder. Consider this: If you are in some folder other than root ( C:\ ), the dir1.path method will return:
c:\bogus
but if you are in the root ( C:\ ), it will return:
C:
Notice that in the first one you don't have the backslash (\) at the end. Therefore, you must check to see if you have it or not, and store the right path and name for the new folder in a variable (path_name):
' Create a new folder with the FileSystemObject object.
If Right(Dir1.Path, 1) = "\" Thenpath_name = Dir1.Path & Text1.Text
Else
path_name = Dir1.Path & "\" & Text1.Text
End If
fso.CreateFolder (path_name)
Set fso = Nothing
'To set the folder display to the new folder
Dir1.Path = path_name
Dir1.Refresh
End Sub
This will avoid any errors. Don't forget to check if the folder already exists, and rate my answer.
by true_texan
VB support creating folders. Try this:
dim StrPath as string
StrPath= InputBox(Message, Title, "")
If StrPath <> "" Then MkDir StrPath
Where Message and Title are the message and title you want them to appare in the input box.
I hope it helped
by true_texan
by true_texan
This discussion is closed to new replies.
Trending Web Development posts
Sort by Trending