ASP Getting Started Tutorial: ASP FileSystemObject objects
The FileSystemObject object is used to access the file system on the server.
Let's illustrate the following examples.
<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>
Output results.
File C:winntcursors3dgarro.cur exists.
Instance two.
<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>
Output results.
Folder C:temp exists.
Instance three.
<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>
The output result is.
Drive c:exists.
Drive g:does not exist.