function writeFile(filecontent){
filecontent = new Date()+">>>"+filecontent;
var fso = new ActiveXObject("Scripting.FileSystemObject");
try{
file = fso.GetFile("D:\\logs\\test.txt");
}catch(e){
file = null;
}
if(!file){
//如果没有,创建文件
try{
fso.CreateTextFile("D:\\logs\\test.txt",true);
file = fso.GetFile("D:\\logs\\test.txt");
}catch(Ee){
file = null;
}
}
if(file == null){
alert('创建本地文件失败,file==null');
return;
}
ts = file.OpenAsTextStream(8,true);
ts.WriteLine(filecontent);
ts.Close();
}
js 写文件流 方法
最新推荐文章于 2024-08-12 02:09:06 发布