js+FSO遍历文件夹下文件并显示
作者:
js+FSO遍历文件夹下文件并显示
<SCRIPT language=javascript src="pict/datas.ini"></SCRIPT>
<script language=javascript>
var s="";
for(var i = 0; i < datas.length ; i++){
s+=datas[i]+"||||";
}
document.write(s);
</script>
<script language="javascript">
function init(){
var fso = new ActiveXObject("Scripting.FileSystemObject");
var folder = fso.GetFolder("pict");
var datas = fso.CreateTextFile("pict/datas.ini",true);
datas.WriteLine("var datas = new Array();") ;
var fenum = new Enumerator(folder.Files);
for (var i = 0 ; !fenum.atEnd(); fenum.moveNext(),i++){
datas.WriteLine("datas["+ i +"] = \""+ fenum.item().Name +"\";") ;
}
datas.Close();
//var f1 = fso.GetFile("pict\\a.txt");
for(var file in folder.Files){
alert(file);
//alert("File last modified: " + file.DateLastModified);
}
}
</script>
<input type="button" value="初始化数据" onclick="init()">
<script language=javascript>
var s="";
for(var i = 0; i < datas.length ; i++){
s+=datas[i]+"||||";
}
document.write(s);
</script>
<script language="javascript">
function init(){
var fso = new ActiveXObject("Scripting.FileSystemObject");
var folder = fso.GetFolder("pict");
var datas = fso.CreateTextFile("pict/datas.ini",true);
datas.WriteLine("var datas = new Array();") ;
var fenum = new Enumerator(folder.Files);
for (var i = 0 ; !fenum.atEnd(); fenum.moveNext(),i++){
datas.WriteLine("datas["+ i +"] = \""+ fenum.item().Name +"\";") ;
}
datas.Close();
//var f1 = fso.GetFile("pict\\a.txt");
for(var file in folder.Files){
alert(file);
//alert("File last modified: " + file.DateLastModified);
}
}
</script>
<input type="button" value="初始化数据" onclick="init()">