Click to See Complete Forum and Search --> : File System Object and copying a folder...
artsapimp
Jul 11th, 2001, 02:17 PM
How can I create a form that will make a new folder named whatever I type in a textbox and copies some files from another location to the new folder? Confusing? Let me try again.
You type "Frank" as the name in a textbox and click continue. The next page creates a folder named "Frank" in a specified directory on the server and copies files from another folder "RootFiles" to the "Frank" folder.
I'm not very good at explaining it, I'm sorry.
Thanks for your help.
CreoN
Jul 11th, 2001, 06:51 PM
dim fso
set fso = Server.CreateObject("Scripting.FileSystemObject")
fso.CreateFolder("new folder")
fso.CopyFile "orignial_path","new path"
Should be working...
artsapimp
Jul 11th, 2001, 07:18 PM
I have been playing with this and it's working great. I changed one thing to CopyFolder instead of Files but the same concept pretty much.
One question though - I can't use Server.MapPath(...)? If so what would you do when being hosted through an ISP where you don't know the static path to write?
Thanks again for any help.
CreoN
Jul 11th, 2001, 07:24 PM
You should be able to use it... I've used it and it worked perfect.
artsapimp
Jul 11th, 2001, 07:32 PM
Could you please tell me where I'm messing up? I can't find it.
<%
If Request.Form("Username") = "" Or IsNull(Request.Form("Username")) Then
%>
<form action="Default.asp" method="Post">
<input type="Text" name="Username">
<input type="Submit" value="Sign Up">
</form>
<%
Else
Dim fso
Dim rootFolder
Set fso = Server.CreateObject("Scripting.FileSystemObject")
fso.CreateFolder(Server.MapPath("/" & Request.Form("Username")))
fso.CopyFolder(Server.MapPath("Test"), (Server.MapPath(Request.Form("Username"))), True)
Response.Write("Thank you " & Request.Form("Username") & ", your account has been created")
End If
%>
There error I get refers to the last paren in the CopyFolder line and says I can't use parens when calling a sub.
Thanks for any help.
CreoN
Jul 11th, 2001, 07:43 PM
Hmm.. why the true?
Try removing ,True) and the ( before the target-folder...
artsapimp
Jul 11th, 2001, 08:06 PM
Thank you. With a little touching up that fixed it.
Thanks again.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.