Drag0n Posted March 5, 2009 Author Share Posted March 5, 2009 How would you create a directory using VB6?Please tell me.. I've been looking everywhere Link to comment Share on other sites More sharing options...
unnown Posted March 6, 2009 Share Posted March 6, 2009 call mkdir(make dir :D) Link to comment Share on other sites More sharing options...
Drag0n Posted March 6, 2009 Author Share Posted March 6, 2009 thanks Unnown. Like this?```Call mkdir(\Random_Folder)``` Link to comment Share on other sites More sharing options...
Fulou Posted March 6, 2009 Share Posted March 6, 2009 I ripped this from my source, it has UNC support if required.```'-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-Function DriveExist(ByVal Drive As String) As Boolean'Example, C: , will remove the \ Automatically!'On error, will return false'-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-On Error GoTo ForceFalseDim FSOSet FSO = CreateObject("Scripting.Filesystemobject")  If FSO.DriveExists(Drive) = True Then    DriveExist = True  Else    DriveExist = False  End IfSet FSO = NothingExit FunctionForceFalse:DriveExist = FalseSet FSO = NothingEnd Function'-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-Function CreateFolder(ByVal Path As String) As Boolean' Returns false if failed, True if ftw.' Loops through and makes sure all parent folders exist too!'-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-Dim FSODim Parse, currentpath As StringDim PathLen, Currentlen, i As LongSet FSO = CreateObject("Scripting.Filesystemobject")PathLen = Len(Path)Parse = Split(Path, "\")If Mid(Path, 1, 2) = "\\" Then ' if its a UNC path!  Currentlen = (Len(Parse(2)) + 3)  currentpath = "\\" & Parse(2) & "\"  i = 3Else              ' if its a local path!  Currentlen = (Len(Parse(1)) + 1)  currentpath = Parse(1) & "\"  If DriveExist(Parse(0)) = False Then ' check to see if the drive exists    GoTo Failed  End If  i = 1End If  Do    currentpath = currentpath & Parse(i) & "\"    If FolderExist(currentpath) = False Then      FSO.CreateFolder (currentpath)    End If    Currentlen = Currentlen + Int(Len(Parse(i))) + 1    i = i + 1  Loop Until Currentlen >= PathLenCreateFolder = TrueSet FSO = NothingExit FunctionFailed:CreateFolder = FalseSet FSO = NothingEnd Function``` Link to comment Share on other sites More sharing options...
Drag0n Posted March 6, 2009 Author Share Posted March 6, 2009 That says "Ambiguous error" Link to comment Share on other sites More sharing options...
Fulou Posted March 6, 2009 Share Posted March 6, 2009 Interesting, did you put it in a module? What line does it error on, since it works fine for me :S Link to comment Share on other sites More sharing options...
Drag0n Posted March 6, 2009 Author Share Posted March 6, 2009 Wait- If I'm putting it in a button, I sayButtonDirCreate_Click()Should I put "Call Function CreateFolder" or something? I blanked.. -_-End Sub Link to comment Share on other sites More sharing options...
Fulou Posted March 6, 2009 Share Posted March 6, 2009 ```If CreateFolder(App.path & "\Test folder\Another test folder") = True then MsgBox "Created folder successfully!", VbInformation + VbOkOnly, "Info!"Else MsgBox "Failed to create the folder!", VbCritical + VbOkOnly, "Error!"End if``` Link to comment Share on other sites More sharing options...
unnown Posted March 7, 2009 Share Posted March 7, 2009 really big thing for something that's already done really easy in the source..just look up mkdir in the source Link to comment Share on other sites More sharing options...
Fulou Posted March 7, 2009 Share Posted March 7, 2009 Damn Unnown, raining on my parade again ;) Link to comment Share on other sites More sharing options...
Drag0n Posted March 9, 2009 Author Share Posted March 9, 2009 Never mind. Found a list of commands. Link to comment Share on other sites More sharing options...
unnown Posted March 9, 2009 Share Posted March 9, 2009 lol sorry :P Link to comment Share on other sites More sharing options...
Drag0n Posted March 10, 2009 Author Share Posted March 10, 2009 Thanks everyone! I appreciate your help **a lot**.. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now