Using the
File System Object
to
Copy a File
:
Code:
Highlight
<% strFileSource = Server.Mappath("/test.txt") strFileDestination = (Server.Mappath("./") & "\") CopyFile strFileSource, strFileDestination function CopyFile(strFileSource, strFileDestination) dim fileTo, strError set fso = Server.CreateObject("Scripting.FileSystemObject") if fso.FileExists(strFileSource) then set fileTo = fso.GetFile(strFileSource) fileTo.Copy(strFileDestination) set fileTo = nothing set fso = nothing else strError = "Error - Source file does not exist." response.write strError set fso = nothing exit function end if end function %>