ASP Copy Method
Definition and Usage
Copy method copies a file or folder from one location to another.
syntax:
FileObject.Copy(destination[,overwrite]) FolderObject.Copy(destination[,overwrite])
parameter | description |
---|---|
destination | จำเป็น ตั้งสถานที่ปลายทางของการคัดลอกไฟล์หรือโฟลเดอร์ ไม่อนุญาตให้ใช้ wildcard |
overwrite | เลือกได้ มีความหมายว่าเป็นรายการเลือกว่าจะทำให้ล้างแทนไฟล์หรือโฟลเดอร์ที่มีอยู่แล้วหรือไม่ ค่า True หมายถึงไฟล์หรือโฟลเดอร์สามารถล้างแทนได้ ค่า false หมายถึงไฟล์หรือโฟลเดอร์ไม่สามารถล้างแทนได้ ค่าเริ่มต้นคือ true |
เพื่อตัวอย่างของ File วัตถุ
<% dim fs,f set fs=Server.CreateObject("Scripting.FileSystemObject") set f=fs.GetFile("c:\test.txt") f.Copy("d:\new_file.txt",false) set f=nothing set fs=nothing %>
เพื่อตัวอย่างของ Folder วัตถุ
<% dim fs,fo set fs=Server.CreateObject("Scripting.FileSystemObject") set fo=fs.GetFolder("c:\test") fo.Copy("d:\new_file",false) set fo=nothing set fs=nothing %>