views:

24

answers:

1

Hi There I am hoping that someone can help me with this visualscript filesystemobject question

    <%
'Creating the subfolders'
Public objFSO
Sub Main()
Set objFSO = CreateObject("Scripting.FileSystemObject")
Call GeneratePath("C:\Inetpub\wwwroot\sites")
Call GeneratePath("C:\Inetpub\wwwroot\sitesx")
End Sub
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
%>

I have a form that collects the data that needs to go into the

Call GeneratePath("C:\Inetpub\wwwroot\sites")

in the script above

Example of content in the textarea

Call GeneratePath("C:\Inetpub\wwwroot\sites1")
Call GeneratePath("C:\Inetpub\wwwroot\sites2")
Call GeneratePath("C:\Inetpub\wwwroot\sites3")
Call GeneratePath("C:\Inetpub\wwwroot\sites4")

Is it possible to collect the data in the form in a textarea ? and to submit these into the above script? Something like Request.Form("folders")

I have tried the above but somehow it does not get executed, but also doesn't generate a error...

Any ideas and assistance would be greatly appreciated!

A: 

Don't put code in your textarea, just put the values, ie just put the folder names. Then loop through the text split by carriage return to get the folder names and call the function with each name. Something like:

Dim FolderList, FolderName
FolderList = Split(Request.Form("folders"), vbCrLf)
For Each FolderName In FolderList
 GeneratePath(FolderName)
Next

Where the contents of the Textarea is:

C:\Inetpub\wwwroot\sites1
C:\Inetpub\wwwroot\sites2
C:\Inetpub\wwwroot\sites3
C:\Inetpub\wwwroot\sites4
AUSteve