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.
Why not just create Parent then create Sub? If Parent doesn't already exist that is. Or am I misunderstanding you?
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.
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
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.
Check out the MakeSureDirectoryPathExists() API.
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.
MakeSureDirectoryPathExists() creates the entire path, if it does not exist.
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?
After a quick google search, I found this (http://www.developersdex.com/vb/message.asp?p=640&r=4178633).
It cover's the gist of what you want.
This (http://mentalis.org/apilist/MakeSureDirectoryPathExists.shtml) tells about the API