• Welcome to Valhalla Legends Archive.
 

Creating directories

Started by Networks, November 27, 2005, 09:46 AM

Previous topic - Next topic

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.

Yegg

Why not just create Parent then create Sub? If Parent doesn't already exist that is. Or am I misunderstanding you?

Networks

Quote from: Yegg on November 27, 2005, 09:51 AM
Why not just create Parent then create Sub? If Parent doesn't already exist that is. Or am I misunderstanding you?

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.

l)ragon

#3
    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

How is that so hard 8\


Edit: here
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
*^~·.,¸¸,.·´¯`·.,¸¸,.-·~^*ˆ¨¯¯¨ˆ*^~·.,l)ragon,.-·~^*ˆ¨¯¯¨ˆ*^~·.,¸¸,.·´¯`·.,¸¸,.-·~^*

Yegg

Quote from: l)ragon on November 27, 2005, 05:07 PM
    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

How is that so hard 8\
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.

rabbit

Check out the MakeSureDirectoryPathExists() API.
Grif: Yeah, and the people in the red states are mad because the people in the blue states are mean to them and want them to pay money for roads and schools instead of cool things like NASCAR and shotguns.  Also, there's something about ketchup in there.

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.

rabbit

MakeSureDirectoryPathExists() creates the entire path, if it does not exist.
Grif: Yeah, and the people in the red states are mad because the people in the blue states are mean to them and want them to pay money for roads and schools instead of cool things like NASCAR and shotguns.  Also, there's something about ketchup in there.

Networks

Quote from: rabbit on November 28, 2005, 07:25 PM
MakeSureDirectoryPathExists() creates the entire path, if it does not exist.

Why can't I find that declaration in the API test viewer for VB6?

FrOzeN

After a quick google search, I found this.

It cover's the gist of what you want.
~ FrOzeN

PaiD