Hi all,
heres a recursive proceedure I use to create the folder tree instead of
having it hardcoded.
hth,
Dave
'--------- CODE
Public objFSO
Sub Main()
Set objFSO = CreateObject("Scripting.FileSystemObject")
Call
GeneratePath("C:\test1\test2\test3\test4\test5\test6\test7\test8\test9")
End Sub
' ---------------------------------------------------------------------
'* @info Generate a folder tree from the path
'*
'* @param (String) Path
'* @return (Boolean) Folder Exists: Recursion continues (Y/N)
' ---------------------------------------------------------------------
Function GeneratePath(pFolderPath)
GeneratePath = False
If Not objFSO.FolderExists(pFolderPath) Then
If GeneratePath(objFSO.GetParentFolderName(pFolderPath)) Then
GeneratePath = True
Call objFSO.CreateFolder(pFolderPath)
End If
Else
GeneratePath = True
End If
End Function
Call Main
'------- END CODE
"LiquidJ" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> The same way you're trying to create the "client" directory...
>
> Pseudocode:
> If not exists (c:\Program Files)
> CreateFolder(c:\Program Files)
> end if
>
> if not exists (c:\Program Files\xpto)
> CreateFolder(c:\Program Files\xpto)
> endif
>
> if not exists (c:\program files\xpto\123)
> CreateFolder(c:\program files\xpto\123)
> endif
>
> if not exists (c:\program files\xpto\123\client)
> CreateFolder(c:\program files\xpto\123\client)
> endif
>
>
> Of course, the previous example can be cleaned up and optimized greatly,
but
> it shows the basic idea...
>
>
> {L}
>
>
>
> "Richard M." <(E-Mail Removed)> wrote in message
> news:08d101c3a3b4$c95382c0$(E-Mail Removed)...
> The only folder that exists is "Program Files".
> How can i create the other subdirectories.
> Can you give me an example?
>
> Thanks,
>
> >-----Original Message-----
> >Richard, you're going to have to check for the existance
> (or non-existance
> >as the case may be) of each subdirectory before calling
> CreateFolder(). In
> >your example, if any of the "Program Files", "xpto",
> or "123" directories do
> >not exist, you will not be able to create a "\Program
> Files\xpto\123\client"
> >directory using CreateFolder().
> >
> >
> >{L}
> >
> >
> >
> >"Richard M." <(E-Mail Removed)> wrote
> in message
> >news:080601c3a3ae$0c552710$(E-Mail Removed)...
> >Hi,
> >
> >Iīm using vbscript, and the problem is if i put inthe
> >script
> >fs.CreateFolder(""c:\test"), the folder was created.
> >If i put
> >fs.CreateFolder(""c:\Program Files\xpto\123\client\") i
> >had an error "path not found".
> >
> >He only creates one directory in c:, but doesnīt create
> >the subdirectories.
> >
> >Please help, itīs URGENT
> >
> >Best Regards
> >
> >
> >.
> >
>
>
|