Results 1 to 7 of 7

Thread: File System Object and copying a folder...

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2000
    Posts
    323

    File System Object and copying a folder...

    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.
    If you think education is expensive, try ignorance.

  2. #2
    Lively Member
    Join Date
    Mar 2001
    Location
    Sweden
    Posts
    115
    Code:
    dim fso
    set fso = Server.CreateObject("Scripting.FileSystemObject")
    fso.CreateFolder("new folder")
    fso.CopyFile "orignial_path","new path"
    Should be working...

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2000
    Posts
    323

    Thank you.

    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.
    If you think education is expensive, try ignorance.

  4. #4
    Lively Member
    Join Date
    Mar 2001
    Location
    Sweden
    Posts
    115
    You should be able to use it... I've used it and it worked perfect.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2000
    Posts
    323
    Could you please tell me where I'm messing up? I can't find it.
    Code:
    <%
    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.
    If you think education is expensive, try ignorance.

  6. #6
    Lively Member
    Join Date
    Mar 2001
    Location
    Sweden
    Posts
    115
    Hmm.. why the true?
    Try removing ,True) and the ( before the target-folder...

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2000
    Posts
    323
    Thank you. With a little touching up that fixed it.

    Thanks again.
    If you think education is expensive, try ignorance.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width