PDA

View Full Version : create multiple folders in ASP, (the whole tree)


johnnyb
04-06-2003, 04:25 AM
Hello,

I am looking for a way to create a whole folder tree using ASP. I already know how to create a folder using the fileSystemObject, what I want to do is the equivalent of:


set folderMaker=Server.CreateObject("Scripting.FileSystemObject")
Path = folderMaker.CreateFolder(basePath&"/testFolder/test2")

where neither testFolder OR test2 exist yet.

Is this possible? and if so how would I do it?

JB

Morgoth
04-06-2003, 07:44 PM
Ok, so what you are saying is, you want ASP to create a folder inside of another folder and both folders don't already exsist?

<%
dim fs,f, folder1, folder2
set fs=Server.CreateObject("Scripting.FileSystemObject")

' It will not work with only this code:
' set f=fs.CreateFolder("c:\Folder1\Folder2")
' It will give you an error saying that it's unable to find the path;
' Error Type:
' Microsoft VBScript runtime (0x800A004C)
' Path not found

folder1 = "Folder1"
folder2 = "Folder2"

' So, you can take this code, and create the first folder:
set f=fs.CreateFolder("c:\" & folder1)

' Then you can create the second folder knowing the first folder is there:
set f=fs.CreateFolder("c:\" & folder1 & folder2)

set f=nothing
set fs=nothing
%>


Does this help you?

Thanks goes to: http://www.w3schools.com/asp/met_createfolder.asp

johnnyb
04-06-2003, 07:47 PM
Yup, that helps.

I figured that's how I'd have to do it, but I was hoping that it could all be done in one step, unfortunately, it doesn't look like it can.

This has confirmed the other research that I've been doing. If anyone has info to the contrary, let us know!

Morgoth
04-06-2003, 07:51 PM
From what I know, I believe this is the only way, unless you use a custom made component other then FSO, that would differently...

There might be a way that can help you for your needs exactly, if you tell us what you are trying to do...