<script language="vbscript" type="text/vbscript">
document.write("正在重复创建、写入和删除文本文件50次...")
Dim thetime3,tempfile,iserr,t1,FsoObj,tempfileOBJ,t2,i
set FsoObj=Server.CreateObject("Scripting.FileSystemObject")
iserr=False
t1=timer
tempfile=server.MapPath("./") & "\aspchecktest.txt"
For i=1 To 50
Err.Clear
Set tempfileOBJ = FsoObj.CreateTextFile(tempfile,true)
If Err <> 0 Then
document.write("创建文件错误!")
iserr=True
Err.Clear
Exit For
End If
tempfileOBJ.WriteLine "Only for test. Ajiang ASPcheck"
If Err <> 0 Then
document.write("写入文件错误!")
iserr=True
Err.Clear
Exit For
End If
tempfileOBJ.close
Set tempfileOBJ = FsoObj.GetFile(tempfile)
tempfileOBJ.Delete
If Err <> 0 Then
document.write("删除文件错误!")
iserr=True
Err.Clear
Exit For
end if
Set tempfileOBJ=Nothing
Next
t2=timer
If Not iserr Then
thetime3=cstr(int(( (t2-t1)*10000 )+0.5)/10)
document.write("...已完成!本服务器执行此操作共耗时 <font color=red>" & thetime3 & " 毫秒")
End If
</script>
提示如图:
根据上面提示我找到是set FsoObj=Server.CreateObject("Scripting.FileSystemObject")这句话出错,提示说此处需要物件‘server’,可我这儿明明有啊,晕了,不知道是什么原因,请高手们帮忙了啊,先谢谢了!
------解决方案--------------------------------------------------------
这是后台创建脚本的方法.
前台用
set FsoObj=CreateObject("Scripting.FileSystemObject")
不过一般是没有权限的.
------解决方案--------------------------------------------------------
var FsoObj=new ActiveXObject("Scripting.FileSystemObject");
除非在hta中运行