Sideway BICK BlogSideway BICK BLOG from Sideway

A Sideway to Sideway Home

Link:http://output.to/sideway/default.asp?qno=130300019

TextStream Object, FileSystemObject Component, ASP Server Component

TextStream Object

TextStream object of FileSystemObject component is related to manipulating the contents of a text file sequentially. Unlike other object in the FileSystemObject component, the TextSteam object returned from the FileSystemObject object provides an intermediate variable placeholder as the representation of the contents of the sequential text stream of the text file for manipulation.

Methods

Method Description
Close to close the specified TextStream object instance if opened.
Read to read and return a specified number of characters from the specified TextStream object instance.
ReadAll to read and return all entire TextStream characters from the specified TextStream object instance.
ReadLine to read and return one entire line of TextStream characters, excluding the newline character, from the specified TextStream object instance.
Skip to skip the returning of a specified number of TextStream characters from the specified TextStream object instance during reading.
SkipLine to skip the returning of next entire line of TextStream characters from the specified TextStream object instance during reading.
Write to write the specified string to the specified TextStream object instance.
WriteBlankLines to write the specified number of newline characters to the specified TextStream object instance.
WriteLine to write the specified string and a newline character to the specified TextStream object instance.

Properties

Property Description
AtEndOfLine a read only property to check whether the file pointer is positioned immediately before the end-of-line marker in the specified TextStream object instance or not.
AtEndOfStream a read only property to check whether the file pointer is positioned immediately at the end of the specified TextStream object instance or not.
Column a read only property to get the column number of the current character position in the specified file object instance.
Line a read only property to get the line number of the current line position in the specified file object instance.

Remarks

The methods and properties of TextStream object can be grouped into

  • TextStream Inforamtion: AtEndOfLine; AtEndOfStream; Column; Line
  • TextStream Manipulation: Close; Read; ReadAll; ReadLine; Skip; SkipLine; Write; WriteBlankLines; WriteLine

Link:http://output.to/sideway/default.asp?qno=130300020

GetSpecialFolder, Drives, FileSystemObject Object, ASP Server Component, Built-in Function

FileSystemObject Object

One function of FileSystemObject object is the manipulation of general file system information. One type of the file system manipulation is related to the local system. The other type of the file system manipulation is related to the path string editing and the path string need not be an existing path.

FileSystemObject.GetSpecialFolder Method

FileSystemObject.GetSpecialFolder method is the method to return an instance of a Folder object corresponding to the specified special folder specification related to the specified FileSystemObject Object..

Syntax:

FileSystemObjectName.GetSpecialFolder(folderspec)

 Or in VBScript. Imply

Set FolderObjectName = FileSystemObjectName.GetSpecialFolder(folderspec)

 Or in JScript. Imply

FolderObjectName = FileSystemObjectName.GetSpecialFolder(folderspec)

Parameters:

FolderObjectName

The parameter "FolderObjectName" is the name assigned to the instance of the Folder object created by the method using the FileSystemObjectName.GetSpecialFolder Method.

FileSystemObjectName

The parameter "FileSystemObjectName" is used to specify the name of the instance of the FileSystemObject Object related to.

folderspec

The parameter "folderspec" is used to specify  the name of the special folder to be returned. The value of parameter "folderspec" can be

Constant Value Description
WindowsFolder 0 The "WindowsFolder" contains files installed by the Windows operating system.
SystemFolder 1 The "System Folder" contains files of libraries, fonts, and device drivers, installed by the Windows operating system.
TemporaryFolder 2 The "Temporary Folder" contains temporary files stored by the Windows operating system, The path can be found in the TMP environment variable.

Return Values:

Folder object

The method returns a Folder object of the special system folder corresponding to the specified folderspec related to the specified FileSystemObject Object. 

Remarks:

FileSystemObjectName should always refer to a FileSystemObject Object

Examples:

  • Example of using the GetSpecialFolder method to create an instance of "TemporaryFolder" object

    ASP VBScript command:

    <script runat="server" language="VBScript">
    Dim fso, tfoldero
    Const TemporaryFolder = 2
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set tfoldero = fso.GetSpecialFolder(TemporaryFolder)
    response.write tfoldero.name </script>

    HTML web page ouput:

    Temp

  • Example of using the GetSpecialFolder method to create an instance of "TemporaryFolder" object

    ASP JScript command:

    <script runat="server" language="JScript">
    var fso, tfoldero, TemporaryFolder = 2;
    fso = new ActiveXObject("Scripting.FileSystemObject");
    tfoldero = fso.GetSpecialFolder(TemporaryFolder);
    Response.Write(tfoldero.name);
    </script>

    HTML web page ouput:

    Temp

FileSystemObject.Drives Collection

FileSystemObject.Drives Collection is used to return the collection of all Drive objects available on the file system of the local machine related to  the specified FileSystemObject Object.

Syntax:

FileSystemObjectName.Drives

 Or in VBScript. Imply

Set DrivesCollectionName = FileSystemObjectName.Drives

 Or in JScript. Imply

DrivesCollectionName = new Enumerator(FileSystemObjectName.Drives)

Parameters:

DrivesCollectionName

The parameter "DrivesCollectionName" is the name assigned to the instance of the Drives collection returned by the Collection Property using the FileSystemObjectName.Drives Property.

FileSystemObjectName

The parameter "FileSystemObjectName" is used to specify the name of the instance of the FileSystemObject Object related to.

Return Values:

Drives collection

The property returns a Collection of all available Drive objects related to the specified FileSystemObject Object. 

Remarks:

FileSystemObjectName should always refer to a FileSystemObject Object.

Properties of Collection for VBScript:

Property Description
Count a read only property to return the number of items in the Drives collection.
Item to return an item corresponding to the specified key.

Methods of Enumerator for JScript:

Method Description
atEnd to check whether the enumerator is at the end of the collection
Item to return the current item of the Drive object in the enumerator of the Drives collection.
moveFirst> moveFirst to reset the location of current item in the enumerator of the collection to the first item in the enumerator of the collection
moveNext to move the location of current item in the enumerator of the collection to the next item in the enumerator of the collection

Remarks:

FileSystemObjectName should always refer to a FileSystemObject Object.

The term "Drive" under the FSO model can be a hard disk, a CD-Rom drive, a RAM disk or logically connected network Drive etc.

For removable-media drives, the media is not necessary to be inserted into the removable-media drives before these removable-media drives can be appeared in the Drives collection.

For JScript, the Collection is packed as an Enumerator at which Count property is not supported. And the supported properties are atEnd() method, item method, moveFirst method, and moveNext Method.

Examples:

  • Example of using the Drives property to return an collection of all "Drive" objects available

    ASP VBScript command:

    <script runat="server" language="VBScript">
    Dim fso, drivesc
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set drivesc = fso.Drives
    Response.Write drivesc.Count
    </script>

    HTML web page ouput:

    3

  • Example of using the Drives property to return an collection of all "Drive" objects available

    ASP JScript command:

    <script runat="server" language="JScript">
    var fso, drivese;
    fso = new ActiveXObject("Scripting.FileSystemObject");
    drivese = new Enumerator(fso.Drives);
    </script>

    HTML web page ouput:

     

Drives.Count Property (VBScript)

Drives.Count Property of FileSystemObject.Drives Collection is a read only property used to return the number of drive objects in the specified FileSystemObject.Drives collection  related to the specified FileSystemObject object. 

Syntax:

DrivesCollectionName.Count

 Or in VBScript. Imply

 DrivesCollectionName.Count

Parameters:

FileSystemObjectName

The parameter "DrivesCollectionName" is used to specify the name of the instance of the Drives Collection related to.

Return Values:

Number of Drive Objects

The property returns the number of drive objects included in the specified Drives Collections.

Drives.Item Property (VBScript)

Drives.Item Property of FileSystemObject.Drives Collection is used to return a Drive object in the FileSystemObject.Drives collection corresponding to the specified key in the specified FileSystemObject.Drives collection related to the specified FileSystemObject object.

Syntax:

DrivesCollectionName.Item(key)

 Or in VBScript. Imply

 DrivesCollectionName.Item(key)

Parameters:

FileSystemObjectName

The parameter "DrivesCollectionName" is used to specify the name of the instance of the Drives Collection related to.

Return Values:

 Drive Object

The property returns a drive object corresponding to the specified key in the specified Drives Collection. 

Examples:

  • Example of using the Drives property to return the Count and Item properties an collection of all "Drive" objects available

    ASP VBScript command:

    <script runat="server" language="VBScript">
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set drivesc = fso.Drives
    Response.Write drives.count & "<br>"
    For Each driveo in drivesc
    Response.Write driveo.DriveLetter & " drive ready: " & driveo.IsReady &"<br>"
    Next
    Response.Write "<br>"
    Response.Write "E drive ready: " & drivesc.item("E").IsReady
    </script>

    HTML web page ouput:

    3
    C drive ready: True
    D drive ready: True
    E drive ready: False

    E drive ready: False

DrivesEnum.atEnd Method

DrivesEnum.atEnd Method of the Enumerator of FileSystemObject.Drives Collection is used to check whether the enumerator is at the end of the colloection and returns a Boolean true value to indicate the Enumerator is at the end of the enumerator of the specified FileSystemObject.Drives collection related to the specified FileSystemObject object. 

Syntax:

DrivesEnumName.atEnd

 Or in JScript. Imply

DrivesEnumName.atEnd

Parameters:

DrivesEnumName

The parameter "DrivesEnumName" is used to specify the name of the instance of the Drives Enumerator related to.

Return Values:

Boolean

The method returns a Boolean true value to indicate the specified enumerator is at the end of the enumerator of the specified FileSystemObject.Drives collection. A Boolean false value indicates that  the specified enumerator is not  at the end of the enumerator or the enumerator of the collection is empty.

DrivesEnum.item Method

DrivesEnum.item Method of the Enumerator of FileSystemObject.Drives Collection is used to return the current item of the Drive object in the specified enumerator of the Drives collection corresponding to the specified FileSystemObject.Drives Collection related to the specified FileSystemObject object.

Syntax:

DrivesEnumName.item

 Or in JScript. Imply

 DrivesEnumName.item

Parameters:

DrivesEnumName

The parameter "DrivesEnumName" is used to specify the name of the instance of the Drives Enumerator related to.

Return Values:

Drive object

The method returns the current item of the Drive object in the specified enumerator of the Drives collection corresponding to the specified FileSystemObject.Drives Collection related to the specified FileSystemObject object. The return values is "undefined" if the enumerator of the collection is empty or the current item is undefined.

DrivesEnum.moveFirst Method

DrivesEnum.moveFirst Method of the Enumerator of FileSystemObject.Drives Collection is used to reset the location of the current item of the Drive object to the first item in the specified enumerator of the Drives collection corresponding to the specified FileSystemObject.Drives Collection related to the specified FileSystemObject object.

Syntax:

DrivesEnumName.moveFirst

 Or in JScript. Imply

 DrivesEnumName.moveFirst

Parameters:

DrivesEnumName

The parameter "DrivesEnumName" is used to specify the name of the instance of the Drives Enumerator related to.

Remarks:

The method reset the location of the current item of the specified enumerator to the first item of the specified enumerator of the Drives collection corresponding to the specified FileSystemObject.Drives Collection related to the specified FileSystemObject object. If there is no item in the collection, the current item is set to undefined.

DrivesEnum.moveNext Method

DrivesEnum.moveNext Method of the Enumerator of FileSystemObject.Drives Collection is used to move the location of the current item of the Drive object to the next item in the specified enumerator of the Drives collection corresponding to the specified FileSystemObject.Drives Collection related to the specified FileSystemObject object.

Syntax:

DrivesEnumName.moveNext

 Or in JScript. Imply

 DrivesEnumName.moveNext

Parameters:

DrivesEnumName

The parameter "DrivesEnumName" is used to specify the name of the instance of the Drives Enumerator related to.

Remarks:

The method movet the location of the current item of the specified enumerator to the next item of the specified enumerator of the Drives collection corresponding to the specified FileSystemObject.Drives Collection related to the specified FileSystemObject object. If there is no item or no more item in the collection, the current item is set to undefined.

Examples:

  • Example of using methods of the Enumerator of  a Drives collection to return the Drive properties of  an collection of all "Drive" objects available

    ASP JScript command:

    <script runat="server" language="JScript">
    var fso, drivese;
    fso = new ActiveXObject("Scripting.FileSystemObject");
    drivese = new Enumerator(fso.Drives);
    for (; !drivese.atEnd(); drivese.moveNext()) {
    driveo = drivese.item();
    drivese.moveNext;
    Response.Write(driveo.DriveLetter + " drive ready: " +  driveo.IsReady +"<br>")
    }
    drivese.moveFirst(); drivese.moveNext(); drivese.moveNext();
    Response.Write("E drive ready: " + drivese.item().IsReady)
    </script>

    HTML web page ouput:

    C drive ready: True
    D drive ready: True
    E drive ready: False

    E drive ready: False

Link:http://output.to/sideway/default.asp?qno=130300018

ASP Server Component, Built-in Function, File Object

File Object

File object of FileSystemObject component is related to manipulating file of a file system of the web server located.

Methods

Method Description
Copy to copy the specified file object instance to the destination location.
Delete to delete the specified file object instance.
Move to move the specified file object instance to the destination location.
OpenAsTextStream to return a TextStream object corresponding to the specified file after opening for text manipulation.

Properties

Property Description
Attributes to set or get the folder attributes of the specified file object instance.
DateCreated a read only property to get the created date and time attribute of the specified file object instance.
DateLastAccessed a read only property to get the last accessed date and time attribute of the specified file object instance.
DateLastModified a read only property to get the last modified date and time attribute of the specified file object instance.
Drive a read only property to get the drive letter on which the specified file object instance resides.
Name  to set or get the name of the specified file object instance.
ParentFolder a read only property to return the folder object of the parent of the specified file object instance.
Path to get the path of the specified file object instance
ShortName to get the short name with 8.3 naming convention of the specified file object instance
ShortPath to get the short path with 8.3 naming convention of the specified file object instance
Size to get the size, in bytes, of the specified file object instance.
Type to get the type information of the specified file object instance

Remarks

The methods and properties of File object can be grouped into

  • File Inforamtion
    • File Space: Size
    • File Details: Drive; Name; Path; ShortName; ShortPath; Type
    • File Properties: Attributes; DateCreated; DateLastAccessed; DateLastModified;
  • File Manipulation
    • File operation: Copy; Delete; Move
    • File Object Manipulation: OpenAsTextStream; ParentFolder
Previous Month  MAR  2013  Next Month
SMTWTFS
12
3456789
10111213141516
17181920212223
24252627282930
31

Previous Month  MAR  2012  Next Month
SMTWTFS
123
45678910
11121314151617
18192021222324
25262728293031

Sideway BICK Blog

16/03


Copyright © 2000-2020 Sideway . All rights reserved Disclaimerslast modified on 26 January 2013