ASP FileSystemObject File System example

Source: Internet
Author: User
Tags object model

<body>
<%
Set Fs=server.createobject ("Scripting.FileSystemObject")
if ( Fs.fileexists ("C:windowscursorsxxx.cur")) =true then
Response.Write ("File C:windowscursorsxxx.cur exists.
Else
      Response.Write ("File c:windowscursorsxxx.cur does not exist.") ")
End If
Set fs=nothing
%>
</body>
<body>
;%
Set Fs=server.createobject ("Scripting.FileSystemObject")
If Fs.folderexists ("c:emp") = True Then
       Response.Write ("folder C:emp exists.")
Else
      Response.Write ("folder C:emp does not exist.") ")
End If
Set fs=nothing
%>
</body>

<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>

Because the FSO object is contained in the Scripting type library (Scrrun.dll), you first need to refer to the file in the project before you use it, click Project, Reference, and then select Microsoft Scripting Runtime in the Reference dialog box check box, and then click OK.

There are two ways to create an FSO object, one of which is to declare a variable as the FSO object type: Dim fsotest As New FileSystemObject, and the other is to create an FSO object through the CreateObject method: Set fsotest = CreateObject ("Scripting.FileSystemObject"). The actual use of the specific declaration method, according to the use of personal habits.

After the FSO object model is created, it is possible to access the properties of the subordinate objects by using the methods created by the object model to obtain the required information or to perform related operations, and the specific methods are described below

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.