Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Active Server Pages (ASP)
Expertise: Beginner
Jan 18, 2000

Copy and Delete Files Using ASP Code

Question:

How do I copy files from point A to point B from within my ASP page? After I have used the file that has been transferred to point B, how do I erase it?

Answer:

You can use the FileSystem object to copy files from one place to another. To copy files, use the FileCopy method. To delete file, use the DeleteFile method.

Dim fs
Set fs = CreateObject("Scripting.FileSystemObject")
fs.CopyFile "Path and File Name of Source", "Path and File Name of Destination"
... your other processing code here
' -- delete the file
fs.DeleteFile "Path and File Name of File to Delete"

You can either hard code the path and file name of the files if you know them (for example, "c:\inetpub\wwwroot\filename.dat"), or you can use the Server.MapPath() method to obtain the DOS file name of a file within your site.

DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date