<html>
<body>
<%
Set fs=Server.CreateObject("Scripting.FileSystemObject")
If (fs.FileExists("c:\windows\cursors\xxx.cur"))=true Then
Response.Write("文件 c:\windows\cursors\xxx.cur 存在。")
Else
Response.Write("文件 c:\windows\cursors\xxx.cur 不存在。")
End If
set fs=nothing
%>
</body>
</html>
本實(shí)例運(yùn)行結(jié)果如下:
文件 c:\windows\cursors\xxx.cur 不存在。
指定的文件夾存在嗎?
本例演示如何使用FolderExists方法探測(cè)某文件夾是否存在。
本示例代碼如下:
以下為引用的內(nèi)容:
<html>
<body>
<%
Set fs=Server.CreateObject("Scripting.FileSystemObject")
If fs.FolderExists("c:\temp") = true Then
Response.Write("文件夾 c:\temp 存在。")
Else
Response.Write("文件夾 c:\temp 不存在。")
End If
set fs=nothing
%>
</body>
</html>
<html>
<body>
<%
Set fs=Server.CreateObject("Scripting.FileSystemObject")
if fs.driveexists("c:") = true then
Response.Write("驅(qū)動(dòng)器 c: 存在。")
Else
Response.Write("驅(qū)動(dòng)器 c: 不存在。")
End If
Response.write("<br>")
if fs.driveexists("g:") = true then
Response.Write("驅(qū)動(dòng)器 g: 存在。")
Else
Response.Write("驅(qū)動(dòng)器 g: 不存在。")
End If
set fs=nothing
%>
</body>
</html>