Valhalla Legends Forums Archive | Visual Basic Programming | Creating directories

AuthorMessageTime
Networks
I understand how to make directories using mkdir() but you will recieve an error if the parent directory of a sub directory you're creating doesn't exist. Simply if I try to create ...\Parent\Sub, Sub will not be created because Parent is not already created. In .NET the CreateDirectory() function will create both on demand vb6 won't. Is there another way? Thank you.
November 27, 2005, 3:46 PM
Yegg
Why not just create Parent then create Sub? If Parent doesn't already exist that is. Or am I misunderstanding you?
November 27, 2005, 3:51 PM
Networks
[quote author=Yegg link=topic=13358.msg135477#msg135477 date=1133106661]
Why not just create Parent then create Sub? If Parent doesn't already exist that is. Or am I misunderstanding you?
[/quote]

That requires parsing through a string I don't feel like parsing through but if I have to I will, right now I want to see if it's possible to do it all together.
November 27, 2005, 3:59 PM
dRAgoN
[code]    If Dir(ParentDir) = "" Then 'Parent dir does not exist
        'Make the parent directory
    Else                        'Parent dir exists
        '
    End If
   
    If Dir(ChildDir) = "" Then  'Child dir does not exist
        'Make the child directory
    Else                        'Child dir exists
        '
    End If[/code]
How is that so hard 8\


Edit: here
[code]Public Function DirExists(ByVal strFolder As String) As Boolean
    If Dir(strFolder) = "" Then 'Dir does not exist
        DirExists = False
    Else                        'Dir exists
        DirExists = True
    End If
End Function[/code]
November 27, 2005, 11:07 PM
Yegg
[quote author=l)ragon link=topic=13358.msg135506#msg135506 date=1133132844]
[code]    If Dir(ParentDir) = "" Then 'Parent dir does not exist
        'Make the parent directory
    Else                        'Parent dir exists
        '
    End If
   
    If Dir(ChildDir) = "" Then  'Child dir does not exist
        'Make the child directory
    Else                        'Child dir exists
        '
    End If[/code]
How is that so hard 8\
[/quote]
That's what I was wondering. But what I think he is looking for is a function (or other method) that does this for him. But any other method would still in turn have to parse the string. So what I would do is simply parse it on my own.
November 28, 2005, 1:03 AM
rabbit
Check out the MakeSureDirectoryPathExists() API.
November 28, 2005, 2:07 AM
Networks
I meant creating a directory such as:
C:/Test/Test2

...where parent directory Test doesn't exist and could be anything (user input). Test2 could also be anything.
November 28, 2005, 9:56 PM
rabbit
MakeSureDirectoryPathExists() creates the entire path, if it does not exist.
November 29, 2005, 1:25 AM
Networks
[quote author=rabbit link=topic=13358.msg135642#msg135642 date=1133227514]
MakeSureDirectoryPathExists() creates the entire path, if it does not exist.
[/quote]

Why can't I find that declaration in the API test viewer for VB6?
November 29, 2005, 5:05 AM
FrOzeN
After a quick google search, I found this.

It cover's the gist of what you want.
November 29, 2005, 5:19 AM
PaiD
This tells about the API
November 29, 2005, 6:46 PM

Search