?
This document uses PHP Chinese website manual Release
JScript? | 語(yǔ)言參考 |
將指定文件或文件夾從一個(gè)位置復(fù)制到另一位置。
object.Copy( destination[, overwrite] );
object
必選項(xiàng)。 應(yīng)為 File 或 Folder 對(duì)象的名稱。
destination
必選項(xiàng)。 復(fù)制文件或文件夾的目的位置。 不允許通配字符。
overwrite
可選項(xiàng)。 Boolean 值,如果要覆蓋已有文件或文件夾,則為 True (默認(rèn));否則,則為 False 。
Copy 方法對(duì)單個(gè) File 或 Folder 所產(chǎn)生的結(jié)果和使用 FileSystemObject.CopyFile 或 FileSystemObject.CopyFolder 所執(zhí)行的操作結(jié)果一樣,其中,后者把由 object 所引用的文件或文件夾作為參數(shù)傳遞。 但是請(qǐng)注意,后兩種替換方法能夠復(fù)制多個(gè)文件或文件夾。
下面的例子說(shuō)明了 Copy 方法的用法。
var fso, f;
fso = new ActiveXObject("Scripting.FileSystemObject");
f = fso.CreateTextFile("c:\\testfile.txt", true);
f.WriteLine("This is a test.");
f.Close();
f = fso.GetFile("c:\\testfile.txt");
f.Copy("c:\\windows\\desktop\\test2.txt");
CopyFile 方法 | CopyFolder 方法 | Delete 方法 | Move 方法 | OpenAsTextStream 方法應(yīng)用于: File 對(duì)象 | Folder 對(duì)象