Introduction to ASP Programming (17): Operation of the FSO component folder

Source: Internet
Author: User
After the drive is finished, the folder is then manipulated. These include extracting folder information, creating folders, deleting folders, copying folders, moving folders, and so on. Here's a concrete look.
First, FSO. GetFolder
A look is clear, is the extraction folder. Which folder is that specifically extracted? Definitely follow the path to a folder. Extract it and then display the information about the folder? Whether there is to be specific extraction down. So, look at the program:
1,getfldr.asp
<%
Set fso = CreateObject ("Scripting.FileSystemObject")
Set Fldr = fso. GetFolder ("C:Program Files")
Response.Write "Parent folder name is:" & Fldr & "<br>"
If Fldr. IsRootFolder = True Then
Response.Write "This folder is a folder" & "<br>"
Else
Response.Write "This folder is not a root folder" & "<br>"
End If
Response.Write "Drive name is:" & Fldr. Drive & "<br>"
%>

It is essential to establish a connection to the FSO component first, then set Fldr = FSO. GetFolder ("C:Program Files") sets the Fldr object to be assigned as a reference to the following program.
Fldr. IsRootFolder is to determine whether the folder is a folder and the value is a Boolean (true or false); Fldr. Drive displays the drive letter for the folder.
Second, FSO. CreateFolder
The next more exciting is the creation of a folder through ASP, you can create any folder within your jurisdiction.
2,creatfldr.asp
<%
Set fso = CreateObject ("Scripting.FileSystemObject")
Fso. CreateFolder ("C:cnbruce")
Response.Write "folder name is" & FSO. Getbasename ("C:cnbruce")
%>

Execution procedures, should find C disk more out of the Cnbruce folder, FSO. Getbasename is the extraction folder name.
Third, FSO. DeleteFolder
You can create a folder from ASP, and you can also delete the folder.
3,delfldr.asp
<%
Set fso = CreateObject ("Scripting.FileSystemObject")
Fso. DeleteFolder ("C:cnbruce")
Response.Write "folder deleted"
%>

It is found that the Cnbruce folder that you just created has actually been deleted.
Note that there are times when you need to delete a folder, and a program logic error occurs when the folder does not exist. You should first determine the status of the folder.
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.