fso| Skills
four, FSO. MoveFolder
The main role is to move the folder, which is equivalent to a cut-and-paste action.
5,movefldr. Asp
<%set fso = CreateObject ("Scripting.FileSystemObject")
Fso. CreateFolder ("C:\cnbruce")
Fso. MoveFolder "C:\cnbruce", "C:\Program files\"%>
<a href= "C:\Program files\" > see if the Cnbruce folder has moved over </a>
Format: FSO. MoveFolder "moved folder", "moved to Folder"
This program first establishes the Cnbruce folder under C disk and then moves it below the C:\Program files\ folder.
However, it is also necessary to note that your system folders cannot be moved randomly.
Five, FSO. CopyFolder
Primary role: Copy a folder from one location to another.
6,copyfldr.asp
<%set fso = CreateObject ("Scripting.FileSystemObject")
Fso. CopyFolder "C:\Program files\cnbruce", "C:\"%>
<a href= "C:\" > see if the Cnbruce folder has been copied. </a>
The program is based on the previous movefldr.asp of the implementation of the results of the completion of the copy to the C-packing directory. (the words are comparatively long-_-!)
Of course, its copy is to include the folder inside so subfolders and files are all copied.
Finally, try to delete the C:\Program Files\cnbruce and c:\cnbruce two folders.
However, continue to remind you: do not write wrong, such as written C:\Program Files, then you are miserable: this is called desperate, learning ASP play out the heartbeat out.
The operation of the folder is almost, is it more useful? There is a speech: The good thing is a double-edged sword. Justice and Evil are only a line, pay attention to the formal rational use of this component. However, you can rest assured that the site space service providers to this power has been limited to the dead, how you will not bubble up again:
Then the next step is more subtle: the FSO's operation of the file.
FSO In addition to the drive, folder operation, the most powerful function is the operation of the file. It can be used for counting, content management, searching, generating Dynamic HTML pages, and so on.
first, FSO. OpenTextFile
Needless to say, FSO. OpenTextFile is to open a file, under normal circumstances is open txt text file. So first we create a TXT file, and then through the FSO to read the content.
1,info.txt
Name:cnbrucesex:male
Set up the file, and then make an ASP page, of course, the best two files are in the same directory.
2,opentxt.asp
<%whichfile=server.mappath ("Info.txt")
Set fso = CreateObject ("Scripting.FileSystemObject")
Set txt = fso. OpenTextFile (whichfile,1)
Rline = txt. ReadLine
Rline = rline & "<br>" & txt. ReadLine
Response.Write Rlinetxt. Close%>
Note: Whether you open a drive through the FSO, open a folder, open a file, or open a database that you want to access later, you can only open the absolute physical path address. But the general situation is to upload to the space service provider that can not be very straightforward to understand the location of their own files, so strongly recommend the use of Server.MapPath method: Platform portability, strong applicability.
CreateObject ("Scripting.FileSystemObject") establishes the FSO component connection, the FSO. OpenTextFile (whichfile,1) opens the Info.txt file. The argument "1" means "ForReading: Open the file as read-only." Can't write this file. , and the other parameter "2" means "ForWriting: Open File as Write", and parameter "8" means "ForAppending: Open the file and start writing at the end of the file."
Open the file, and then do you want to display the contents of the file? That's through TXT. The ReadLine method reads an entire line in the text and continues using TXT if it is necessary to continue reading the next line. ReadLine method. Of course, there are other reading methods, such as TXT. Read (7) reads a specified number of characters, txt. ReadAll returns the entire contents of the text.