首页 > 语言 > JavaScript > 正文

JavaScript下利用fso判断文件是否存在的代码

2024-05-06 14:26:06
字体:
来源:转载
供稿:网友
代码如下:
function ReportFileStatus(filespec)
{
var fso, s = filespec;
fso = new ActiveXObject("Scripting.FileSystemObject");
if (fso.FileExists(filespec))
s += " exists.";
else
s += " doesn't exist.";
return(s);
}

采用客户端的 FileSystemObject 对象
例:
代码如下:
function check()
{
var fso;
fso = new ActiveXObject("Scripting.FileSystemObject");
if( fso.FileExists("c://testfile.txt"))
{
alert("Exists!");
}
else
{
alert("not Exists!");
}
} 
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表

图片精选