[thelist] ASP FSO problem.

Phil Turmel philip at turmel.org
Mon Dec 20 07:14:49 CST 2004


Craig said:
<snip>
: set objFSO = CreateObject("Scripting.FileSystemObject")
: set objFolder = objFSO.GetFolder("M:\")
:
: for each item in objFolder.subfolders
:  response.write item.size & "<br />"
: next
</snip>

Keep in mind that reading the .size property of a folder object triggers a 
full recursive scan to generate the total size in that folder...  you must 
have permissions to EVERYTHING in that folder or it will blow you off. 
This is troublesome on a root folder, as Windows tends to create some 
things with odd rights, particularly the swap file and recycler stuff.

In lieu of the single line response.write, try this:

    if item.IsRootFolder then
	Set objDrv = objFSO.GetDrive(item.Drive)
	response.write (objDrv.TotalSize-objDrv.AvailableSpace) & "<br />"
    else
	response.write item.size & "<br />"
    end if

HTH,

Phil Turmel


More information about the thelist mailing list