copy and rename files

Results 1 to 3 of 3

Thread: copy and rename files

  1. #1
    Join Date
    Dec 1969
    Posts
    144

    Default copy and rename files

    I need help in how to write an asp code that will copy a file in example:<BR>tom enters his name into a web page<BR>then hits submit<BR>the asp page the goes and copies a file named "file.asp"<BR>then asp page renames the file to "tomsfile.asp"<BR>here is the code I wrote:<BR><BR>&#060;% set fs=Server.CreateObject("Scripting.FileSystemObject ")<BR> set afile=MyFileObject.GetFile("D:InetPubftproot emplatesfile.asp")<BR> afile.copy "D:InetPubftproot emplateschat.asp","D:InetPubftproot emplateschat2.asp"%&#062; <BR><BR>when run I get an error like this:<BR><BR>Microsoft VBScript runtime error &#039 800a01ad&#039 <BR><BR>ActiveX component can&#039t create object <BR><BR>/addfile.asp, line 192<BR><BR>Please help?<BR>thanks in advance, Ray <BR>

  2. #2
    Jason Buck Guest

    Default RE: copy and rename files

    This is how I do my file copying. (Make sure that you set the directory properties to allow WRITE (ing) to the directory.<BR><BR>Done by right click on the folder and selecting properties and then checking the WRITE option.<BR>&#060;%<BR>dim fn1<BR> <BR> fn1 = "C:webdocs" & "\" & strLogin6 & "\" & request.querystring("doc")<BR><BR>copyto1 = "C:inetdocs\" & strLogin6 & "\" <BR><BR> set fso1 = CreateObject("Scripting.FileSystemObject")<BR> fso1.CopyFile fn1, copyto1,true<BR><BR> %&#062;<BR>What am I doing you ask?<BR><BR>When my users login, they are given a list of documents that are available to them.<BR>Webdocs is a non web accessible document that is stored on the root of the server. <BR>Inetdocs is a virtual directory for docs. In each directory there is a folder that matches the users login. When they select a document. It is copied from Webdocs to Inetdocs(internet docs) and then displayed to the user. Then when they logout or leave the mydocs page all of the files in Inetdocs are deleted.<BR><BR>I hope the file copy info helps you.<BR><BR>If I didn&#039t explain this cleary, please feel free to contact me.<BR><BR>Respectfully,<BR><BR>Jason<BR>webmaster @wnj.com

  3. #3
    Jason Buck Guest

    Default Renaming files

    Sorry, I don&#039t know of a method to rename a file. To do that just copy filea to fileb then delete filea. As follows:<BR>***** TO COPY THE FILE and RENAME IT ******<BR>Dim fso, MyFile<BR>Set fso = CreateObject("Scripting.FileSystemObject")<BR>Set MyFile = fso.GetFile("c: estfile.txt")<BR>MyFile.Copy ("c: est2.txt")<BR><BR>****** TO DELETE THE ORIGINAL FILE ******* You already dimensioned it above<BR>Set MyFile = fso.GetFile("c: estfile.txt")<BR>MyFile.Delete <BR><BR><BR><BR><BR><BR><BR>

Posting Permissions

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