asp入门教程:ASP FileSystemObject 对象
使用FileSystemObject对象是用来存取档案系统的服务器上。
下面我们来举例说明吧.
<html>
<body>
<%
Set fs=Server.CreateObject("Scripting.FileSystemObject")
If (fs.FileExists("c:winntcursors3dgarro.cur"))=true Then
Response.Write("File c:winntcursors3dgarro.cur exists.")
Else
Response.Write("File c:winntcursors3dgarro.cur does not exist.")
End If
set fs=nothing
%>
</body>
</html>
输出结果.
File c:winntcursors3dgarro.cur exists.
实例二.
<html>
<body>
<%
Set fs=Server.CreateObject("Scripting.FileSystemObject")
If fs.FolderExists("c:temp") = true Then
Response.Write("Folder c:temp exists.")
Else
Response.Write("Folder c:temp does not exist.")
End If
set fs=nothing
%>
</body>
</html>
输出结果.
Folder c:temp exists.
实例三.
<html>
<body>
<%
Set fs=Server.CreateObject("Scripting.FileSystemObject")
if fs.driveexists("c:") = true then
Response.Write("Drive c: exists.")
Else
Response.Write("Drive c: does not exist.")
End If
Response.write("<br />")
if fs.driveexists("g:") = true then
Response.Write("Drive g: exists.")
Else
Response.Write("Drive g: does not exist.")
End If
set fs=nothing
%>
</body>
</html>
输出结果为.
Drive c: exists.
Drive g: does not exist.