<script> function ReportFileStatus() { var fso, s = document.all.TextBox1.value; fso = new ActiveXObject("Scripting.FileSystemObject"); if (fso.FileExists(s)) { alert("文件存在"); } else { alert("文件不存在"); } } 注意 调一下IE activex控件设置
这种方法 java中也不行不存在的话会报错的 js中也可以写java代码 啊
<script language="javascript"> function FileExist() { var sfso=new ActiveXObject("Scripting.FileSystemObject"); var fPath="[The path of the file]"; if(sfso.FileExists(fPath)) { alert("Exist"); } else { alert("Doesn't exist"); } } </script>
if (f.exists()) {
// do sth.
}
try {
File file = new File("c://text.txt");
} catch (Exception e) {
}
function ReportFileStatus()
{
var fso, s = document.all.TextBox1.value;
fso = new ActiveXObject("Scripting.FileSystemObject");
if (fso.FileExists(s))
{
alert("文件存在");
}
else
{
alert("文件不存在");
}
}
注意 调一下IE activex控件设置
这种方法 java中也不行不存在的话会报错的
js中也可以写java代码 啊
function FileExist()
{
var sfso=new ActiveXObject("Scripting.FileSystemObject");
var fPath="[The path of the file]";
if(sfso.FileExists(fPath))
{
alert("Exist");
}
else
{
alert("Doesn't exist");
}
}
</script>
不会的,File构造函数的参数路径不存在并不会报错的
可以写一个完整的代码吗
就比如说打开网页立即执行如果c:\1.txt存在则提示“存在” 不存在及“不存在”
c:\1.txt这个也可以换成图片,如果可以读图片的长宽来判断也可以,大侠给段代码学习学习 谢谢了
可以写一个完整的代码吗
就比如说打开网页立即执行如果c:\1.txt存在则提示“存在” 不存在及“不存在”
c:\1.txt这个也可以换成图片,如果可以读图片的长宽来判断也可以,大侠给段代码学习学习 谢谢了