<script type="text/javascript">
var fso, f;
function copyFile()
{
fso = new ActiveXObject("Scripting.FileSystemObject");
f = fso.CreateTextFile("c:\\testfile.txt", true);
f.WriteLine("This is a test.");
f.Close();
f = fso.GetFile("c:\\aaa\\111.txt");
f.Copy("c:\\bbb\\111.txt");
}
</script>
http://blog.csdn.net/langzi1105/archive/2008/12/19/3557032.aspx
以下这个JS脚本,共参考。此例是搜索“C:\My Documents”中的所有HTML文件
<script>
function HTMlist(path){
var txt;
fso = new ActiveXObject("Scripting.FileSystemObject");
fldr = fso.GetFolder(path);
fc = new Enumerator(fldr.files);
for (; !fc.atEnd(); fc.moveNext()) //枚举所有文件
{
s=fc.item(); //取文件对象
if (s.type=="HTML Document"){ //判断是否是“HTML文件”
f = fso.GetFile(s);
ts = f.OpenAsTextStream(1,-2);
txt = ts.ReadAll( ); //读全文
ts.Close( );
txt=txt.toUpperCase();
titl=s.name;
start=txt.indexOf("<TITLE>",0);
if (start!=-1){
start+=7;
end=txt.indexOf("</TITLE>",start);
if (end!=-1) titl=txt.substr(start,end-start);
}
document.write("<a href=\""+s+"\">"+titl+"</a><br>");
}
}
}
HTMlist("C:\\My Documents");
</script>
var fso, f;
function copyFile()
{
fso = new ActiveXObject("Scripting.FileSystemObject");
f = fso.CreateTextFile("c:\\testfile.txt", true);
f.WriteLine("This is a test.");
f.Close();
f = fso.GetFile("c:\\aaa\\111.txt");
f.Copy("c:\\bbb\\111.txt");
}
</script>
http://blog.csdn.net/langzi1105/archive/2008/12/19/3557032.aspx
以下这个JS脚本,共参考。此例是搜索“C:\My Documents”中的所有HTML文件
<script>
function HTMlist(path){
var txt;
fso = new ActiveXObject("Scripting.FileSystemObject");
fldr = fso.GetFolder(path);
fc = new Enumerator(fldr.files);
for (; !fc.atEnd(); fc.moveNext()) //枚举所有文件
{
s=fc.item(); //取文件对象
if (s.type=="HTML Document"){ //判断是否是“HTML文件”
f = fso.GetFile(s);
ts = f.OpenAsTextStream(1,-2);
txt = ts.ReadAll( ); //读全文
ts.Close( );
txt=txt.toUpperCase();
titl=s.name;
start=txt.indexOf("<TITLE>",0);
if (start!=-1){
start+=7;
end=txt.indexOf("</TITLE>",start);
if (end!=-1) titl=txt.substr(start,end-start);
}
document.write("<a href=\""+s+"\">"+titl+"</a><br>");
}
}
}
HTMlist("C:\\My Documents");
</script>