18.01.2013 Views

VBScript Reference Manual for InduSoft Web Studio

VBScript Reference Manual for InduSoft Web Studio

VBScript Reference Manual for InduSoft Web Studio

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>VBScript</strong> <strong>Reference</strong> <strong>Manual</strong> <strong>InduSoft</strong> <strong>Web</strong> <strong>Studio</strong><br />

FileSystemObject (FSO)<br />

The FileSystemObject (FSO) object model is part of the <strong>VBScript</strong> Scripting Type library. It is a COM<br />

component and is used to manipulate the Windows File System from <strong>VBScript</strong>. Note that <strong>VBScript</strong> does<br />

not include commands to access files directly, instead the FSO is used.<br />

The FSO consists of collections (Drives Collection, Folders Collection, and Files Collection) that are a<br />

grouping of like objects, and individual objects (Drive object, Folder object, File object, and TextStream<br />

object). The individual objects are generally derived from a collection or accessed/created directly<br />

through the FSO.<br />

The FSO must be instantiated by the following set of statements:<br />

Dim objFso ‘Declare the variable(s)<br />

Set objFso = CreateObject(“Scripting.FileSystemObject”) ‘Instantiate the FileSystemObject<br />

FSO Properties and Methods<br />

Property Drives<br />

Description: Returns a collection of Drive objects.<br />

Use: Set objDrive = fso.Drives<br />

Arguments: fso<br />

Required. The name of a FileSystemObject object previously instantiated.<br />

Return: An object containing a collection of Drives objects<br />

Remarks: Returns a collection of Drives objects available on the local machine, including networked drives<br />

mapped to the local machine. Removable media drives do not have to have media inserted to<br />

appear in the Drives Collection.<br />

Example: Dim fso, dc, d, strDrvList<br />

Set fso = CreateObject(“Scripting.FileSystemObject”) ‘Instantiate the FSO object<br />

Set dc = fso.Drives ‘Instantiate the Drives collection object<br />

strDrvList = “”<br />

For each d in dc ‘Evaluate each drive in the drives<br />

collection<br />

strDrvList = strDrvList & d.driveLetter & “ – “ ‘Get the Drive letter<br />

If d.DriveType = 3 Then ‘See if a network drive<br />

strDrvList = strDrvList & d.ShareName ‘Yes<br />

ElseIf d.IsReady Then ‘No – is a local drive. Check if ready<br />

strDrvList = strDrvList & d.VolumeName ‘Yes – add to list<br />

End If<br />

strDrvList = strDrvList & vbCrLf ‘Add a Cr & Lf and then get next drive<br />

Next<br />

MsgBox strDrvList ‘Display the list of drives<br />

216 <strong>InduSoft</strong>, Ltd.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!