FSO is as exciting and fascinating as UFO, and of course it is more joyful and sad. Haven't you seen a certain space service provider advertisement: 100MB space only costs 60RMB/year, supports database, supports whatever... When asked, it doesn't support FSO, you will be immediately discouraged. So what exactly is FSO, how powerful is it, and what is its operating principle? This time I have a thorough understanding.
First of all, FSO is the abbreviation of FileSystemObject. Of course, it is our commonly known as the FSO component, which can be used to process drives, folders and files.
It can detect and display the information allocation of system drives; it can also create, change, move and delete folders, and detect whether some given folders exist. If they exist, it can also extract information about the folder, such as the name, the date of creation or last modified, etc. FSO also makes processing files easy.
1. fso.GetDrive
Just as other components are established, FSO references must establish connections.
Set fso=Server.CreateObject("Scripting.FileSystemObject") |
Note that the internal content of CreateObject is no longer MSWC, but Scripting.
Then you can use fso to process the drive. For example, fso.GetDriveName extracts the drive name, and fso.GetDrive also extracts the standard drive name. for example:
1, fso.asp
<%Set fso=Server.CreateObject("Scripting.FileSystemObject")%> <%=fso.GetDriveName("d:")%><br> <%=fso.GetDrive("d:")%> |
You will find that GetDriveName("d:") is "d:", and GetDrive("d:") is the standard "D:", so we usually write fso.GetDrive(fso.GetDriveName(drvPath)) like this to extract a specific driver disk.
2. drv.GetInfo
The above has extracted a specific drive, so whether the specific information of the drive disk is extracted.
2, drv.asp
<% Set fso=Server.CreateObject("Scripting.FileSystemObject") Set drv=fso.GetDrive(fso.GetDriveName("d:")) %> The space size of the disk: <%=drv.TotalSize%><br> The remaining space size of the disk: <%=drv.FreeSpace%> |
The above is just the information extracted from the D drive. Let’s take a general function and continue to test your drivers separately.
3, drvinfo.asp