码迷,mamicode.com
首页 > 其他好文 > 详细

fso查找被删除的文件

时间:2014-07-31 02:31:45      阅读:191      评论:0      收藏:0      [点我收藏+]

标签:style   文件   io   for   cti   html   ar   line   

<html>
<head>
</head>
<body>
源目录:<input id="txtOld" value="F:\开发\fso"></input>
新目录:<input id="txtNew"></input>
对比:<input id="btnCompare" onclick="compareFile()" type="button" value="compare"></input>
<br/>
<textarea id="txtContent" style="width:100%;height:100%"></textarea>
<script>
var subfolder;
var thefile;
var filename;
var FSO = new ActiveXObject("Scripting.FileSystemObject");
//var rootFolder = FSO.getFolder();
var fileArray = [];
var newFileObj = {};
var deleteFileArray = [];
var oldFolderPath = "", newFolderPath = "";

function $(id)
{
return document.getElementById(id);
}

function compareFile()
{
fileArray = [];
deleteFileArray = [];
oldFolderPath = $("txtOld").value;
newFolderPath = $("txtNew").value;
Scan(newFolderPath);
$("txtContent").value = fileArray.join("\r\n");
ScanOldFolder(oldFolderPath );
// alert(fileArray.length);
alert(deleteFileArray.length);
}

function ScanOldFolder(folderName)
{
var folder = FSO.getFolder(folderName);
if (folder.subFolders.count > 0)
{
var fenum = new Enumerator(folder.subFolders);
for (var i = 0 ; !fenum.atEnd(); fenum.moveNext(),i++){
//datas.WriteLine("datas["+ i +"] = \""+ fenum.item().Name +"\";") ;
Scan(fenum.item().path);
}
}
//‘下面一段将文件夹中的文件路径显示在LABEL上并刷新窗体
if (folder.Files.count > 0)
{
var fenum = new Enumerator(folder.Files);
for (var i = 0 ; !fenum.atEnd(); fenum.moveNext(),i++){
//datas.WriteLine("datas["+ i +"] = \""+ fenum.item().Name +"\";") ;

var newPath = fenum.item().path.replace(newFolderPath + "\", "");
if (typeof newFileObj[newPath] != "undefined")
{
deleteFileArray.push(newPath);
}
}
}
}

function Scan(folderName)
{
var folder = FSO.getFolder(folderName);
if (folder.subFolders.count > 0)
{
var fenum = new Enumerator(folder.subFolders);
for (var i = 0 ; !fenum.atEnd(); fenum.moveNext(),i++){
//datas.WriteLine("datas["+ i +"] = \""+ fenum.item().Name +"\";") ;
Scan(fenum.item().path);
}
}
//‘下面一段将文件夹中的文件路径显示在LABEL上并刷新窗体
if (folder.Files.count > 0)
{
var fenum = new Enumerator(folder.Files);
for (var i = 0 ; !fenum.atEnd(); fenum.moveNext(),i++){
//datas.WriteLine("datas["+ i +"] = \""+ fenum.item().Name +"\";") ;
var oldFile = fenum.item().path.replace(oldFolderPath+"\", "");
fileArray.push(oldFile);
newFileObj[oldFile] = oldFile;
}
}
}
</script>
</body>
</html>

fso查找被删除的文件,布布扣,bubuko.com

fso查找被删除的文件

标签:style   文件   io   for   cti   html   ar   line   

原文地址:http://www.cnblogs.com/xjyggd/p/3879597.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!