用途:公司內部網頁可以 刪除/新增/複製/移動 Client端檔案。

 

var fso = new ActiveXObject("Scripting.FileSystemObject");

var SavePath = "C:\\SaveTest2"; //存檔路徑
var FromPath = "C:\\SaveTest1"; //來源路徑

//檢查資料夾是否存在
if (!fso.FolderExists(FromPath))
fso.CreateFolder(FromPath); //不存在則Create

//建立測試資料
var a = fso.CreateTextFile(FromPath + "\\testfile.txt", true);
a.WriteLine("This is a test.");
a.Close();

//檢查資料夾是否存在
if (!fso.FolderExists(SavePath))
fso.CreateFolder(SavePath); //不存在則Create
else
fso.DeleteFile(SavePath + "\\*.*"); //存在則刪除裡面所有檔案

fso.CopyFile(FromPath + "\\*.*", SavePath + "\\"); //複製A資料夾所有檔案到B資料夾


arrow
arrow
    文章標籤
    javascript
    全站熱搜

    伊 發表在 痞客邦 留言(0) 人氣()