Copy File - fs statement

Results 1 to 2 of 2

Thread: Copy File - fs statement

  1. #1
    Join Date
    Dec 1969

    Default Copy File - fs statement

    YOUR RESPONSE:<BR><BR> <BR>Copy file code - fs statement<BR> <BR>bieltan - 8 Oct - 01:18:14 PM<BR>--------------------------------------------------------------------------------<BR>Im trying to copy a picture from one folder to another to hide the original file name to the viewer so when they view source cant reveal anything about the file (picture). It first checks to see if the copied file is in the copied folder, if not it will execute the copying code. If it is in the copied folder it will just used the copied file with the new copied name. I&#039;ve came up with this to execute the copying when someone wants to view the file:<BR><BR>if fs.FileExists("staffpics\" & dbDatabase("First") & dbDatabase("last") & ".jpg")=false then<BR>fs.CopyFile "pictures\" & dbDatabase("ID") & ".jpg" ,"staffpics\" & dbDatabase("First") & dbDatabase("last") & ".jpg"<BR>end if<BR><BR><BR>The error I get is: Microsoft VBScript runtime error &#039;800a004c&#039;<BR><BR>Path not found <BR><BR>Now I can figure out that its not finding the folder lol. But for the life of me i cant figure out why. From examples i&#039;ve seen this in theory should work, but isnt lol. I tried changing quotes to single, no go, and a few other minor changes with still no success. Im really stuck and if anyone could help that be great. Thanks <BR> <BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Copy File - fs statement

    The FileSystem object requires the actual physical path of the file on the server. You can use Server.MapPath to achieve this, for example:<BR><BR>if fs.FileExists(Server.MapPath("staffpics\" & dbDatabase("First") & dbDatabase("last") & ".jpg"))=false then<BR>fs.CopyFile Server.MapPath("pictures\" & dbDatabase("ID") & ".jpg") ,Server.MapPath("staffpics\" & dbDatabase("First") & dbDatabase("last") & ".jpg")<BR>end if

Posting Permissions

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