Fso to copy the entire folder content to another folder

Source: Internet
Author: User

Here is an implementation that copies the content in a folder, including the content in the sub-folder, to the asp code in another folder. During use, you must convert the relative path of the folder to an absolute path. The conversion method is to use server. mappath.

<%
Startfile_1 = "d: \ aaa" 'original folder
Tofile_1 = "c: \ bbb" 'destination folder
Call copyfile (startfile_1, tofile_1)
Response. write "complete"

Function copyfile (startfile, tofile) 'startfile is the original folder path, and tofile is the target folder path.
Set MyFileObject = Server. CreateObject ("Scripting. FileSystemObject ")
Set MyFolder = MyFileObject. GetFolder (startfile)
Domain = Split (startfile, "\") (UBound (Split (startfile ,"\")))
For Each thing in MyFolder. Files 'copy the file
S = Split (thing ,"\")
A = UBound (s)
S3 = Split (thing, "\") ()
MyFileObject. CopyFile thing, tofile & "\" & s3
Next
For Each thing in MyFolder. SubFolders copy SubFolders
S = Split (thing ,"\")
A = UBound (s)
S3 = Split (thing, "\") ()
Response. write thing &"
"
Response. write s1 & "\" & domain & "\" & s3
Response. write"
"
MyFileObject. copyFolder thing, tofile & "\" & s3
Next
End function
%>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.