Sideway BICK BlogSideway BICK BLOG from Sideway

A Sideway to Sideway Home

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

Size / Drive / IsRootFolder / Name / Path, Folder Object, ASP Server Component, Built-in Function

Folder Object

One key function of FileSystemObject Component is the manipulation of folders of the file system.

FolderObject.Size Property

FolderObject.Size property is a property to to get the total size, in bytes, for all files and subfolders contained in the specified folder object instance.

Syntax:

FolderObjectName.Size

 Or in VBScript. Imply

foldersize =FolderObjectName.Size

 Or in JScript. Imply

foldersize =FolderObjectName.Size

Parameters:

foldersize

The parameter "foldersize" is the name assigned to the value returned by the size property referred to the specified Folder object.

FolderObjectName

The parameter "FolderObjectName" is used to specify the name of the instance of the Folder Object related to.

Returns:

Value

The return value of the size property is a value in bytes, for all files and subfolders contained in the specified folder object instance.

Remarks:

FolderObjectName refers to a Folder Object. And File object is another possible alternate object for the Size property.

Examples:

  • Example of using the Size property to get the total size of a folder.

    ASP VBScript command:

    <script runat="server" language="VBScript">
    Dim fso, FolderObjectName, foldersize
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set FolderObjectName = fso.GetFolder("d:\temp")
    foldersize = FolderObjectName.Size
    Response.Write foldersize & "<br />"
    </script>

    HTML web page ouput:

    2600063969

  • Example of using the Size property to get the total size of a folder.

    ASP JScript command:

    <script runat="server" language="JScript">
    var fso, FolderObjectName, foldersize;
    fso = new ActiveXObject("Scripting.FileSystemObject");
    FolderObjectName = fso.GetFolder("d:\\temp");
    foldersize = FolderObjectName.Size 
    Response.Write (foldersize+ "<br />");
    </script>

    HTML web page ouput:

    2600063969

FolderObject.Drive Property

FolderObject.Drive property is a read only property to get and return the drive letter on which the specified folder object instance resided.

Syntax:

FolderObjectName.Drive

 Or in VBScript. Imply

driveletter =FolderObjectName.Drive

 Or in JScript. Imply

driveletter =FolderObjectName.Drive

Parameters:

driveletter

The parameter "driveletter" is the name assigned to the drive letter returned by the drive property referred to the specified Folder object.

FolderObjectName

The parameter "FolderObjectName" is used to specify the name of the instance of the Folder Object related to.

Returns:

string

The return value of the drive property is a string of  the letter name representation of the drive on which the specified folder object instance resided.

Remarks:

FolderObjectName refers to a Folder Object. And File object is another possible alternate object for the Drive property.

Examples:

  • Example of using the Drive property to get the drive letter of a folder.

    ASP VBScript command:

    <script runat="server" language="VBScript">
    Dim fso, FolderObjectName, driveletter
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set FolderObjectName = fso.GetFolder("d:\temp")
    driveletter = FolderObjectName.Drive
    Response.Write driveletter & "<br />"
    </script>

    HTML web page ouput:

    d:

  • Example of using the Drive property to get the drive letter of a folder.

    ASP JScript command:

    <script runat="server" language="JScript">
    var fso, FolderObjectName, driveletter;
    fso = new ActiveXObject("Scripting.FileSystemObject");
    FolderObjectName = fso.GetFolder("d:\\temp");
    driveletter = FolderObjectName.Drive 
    Response.Write (driveletter+ "<br />");
    </script>

    HTML web page ouput:

    d:

FolderObject.IsRootFolder Property

FolderObject.IsrootFolder property is a property to check and return a value indictating whether the specified folder object instance is a root folder or not.

Syntax:

FolderObjectName.IsRootFolder

 Or in VBScript. Imply

rootfolderflag =FolderObjectName.IsRootFolder

 Or in JScript. Imply

rootfolderflag =FolderObjectName.IsRootFolder

Parameters:

rootfolderflag

The parameter "rootfolderflag" is the name assigned to the boolean value returned by the IsRootFolder property referred to the specified Folder object.

FolderObjectName

The parameter "FolderObjectName" is used to specify the name of the instance of the Folder Object related to.

Returns:

boolean value

The return value of the IsRootFolder property is a boolean value to indicate whether the specified folder object instance is a roof folder or not. IsRootFolder property returns True only when the specified folder is the root folder and returns False if the specified folder is not.

Remarks:

FolderObjectName refers to a Folder Object.

Examples:

  • Example of using the IsRootFolder property to check whether a folder is the root folder or not.

    ASP VBScript command:

    <script runat="server" language="VBScript">
    Dim fso, FolderObjectName, rootfolderflag
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set FolderObjectName = fso.GetFolder("d:\temp")
    rootfolderflag= FolderObjectName.IsRootFolder
    Response.Write rootfolderflag & "<br />"
    </script>

    HTML web page ouput:

    False

  • Example of using the IsRootFolder property to check whether a folder is the root folder or not.

    ASP JScript command:

    <script runat="server" language="JScript">
    var fso, FolderObjectName, rootfolderflag;
    fso = new ActiveXObject("Scripting.FileSystemObject");
    FolderObjectName = fso.GetFolder("d:\\temp");
    rootfolderflag = FolderObjectName.IsRootFolder
    Response.Write (rootfolderflag+ "<br />");
    </script>

    HTML web page ouput:

    false

FolderObject.Name Property

FolderObject.Name property is a read/write property to set and return the name of the specified folder object instance.

Syntax:

FolderObjectName.Name [= newname]

 Or in VBScript. Imply

foldername =FolderObjectName.Name

 FolderObjectName.Name =newfoldername

 Or in JScript. Imply

foldername =FolderObjectName.Name

 FolderObjectName.Name =newfoldername

Parameters:

foldername

The parameter "foldername" is the name assigned to the string returned by the Name property referred to the specified Folder object.

FolderObjectName

The parameter "FolderObjectName" is used to specify the name of the instance of the Folder Object related to.

newfoldername

The optional parameter "newfoldername" is used to specify the new folder name to be assigned by the Name property to the folder name referred to the specified Folder object.

Returns:

string

The return value of the Name property is the string of existing folder name refered to the specified folder object instance.

Remarks:

FolderObjectName refers to a Folder Object.  And File object is another possible alternate object for the Name property.

Examples:

  • Example of using the Name property to get and set the name of the specified folder.

    ASP VBScript command:

    <script runat="server" language="VBScript">
    Dim fso, FolderObjectName, foldername
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set FolderObjectName = fso.GetFolder("d:\temp")
    foldername= FolderObjectName.Name
    Response.Write foldername & "<br />"
    FolderObjectName.Name="tempa"
    Response.Write  FolderObjectName.Name & "<br />"
    </script>

    HTML web page output

    temp
    tempa

  • Example of using the Name property to get and set the name of the specified folder.

    ASP JScript command:

    <script runat="server" language="JScript">
    var fso, FolderObjectName, foldername;
    fso = new ActiveXObject("Scripting.FileSystemObject");
    FolderObjectName = fso.GetFolder("d:\\temp");
    foldername = FolderObjectName.Name
    Response.Write (foldername+ "<br />");
    FolderObjectName.Name ="tempa"
    Response.Write (FolderObjectName.Name+ "<br />");
    </script>

    HTML web page outputML web page output

    temp
    tempa

FolderObject.Path Property

FolderObject.Path property is a property to get and return the path of the specified folder object instance.

Syntax:

FolderObjectName.Path

 Or in VBScript. Imply

folderpath =FolderObjectName.Path

 Or in JScript. Imply

folderpath =FolderObjectName.Path

Parameters:

folderpath

The parameter "folderpath" is the name assigned to the string returned by the Name property referred to the specified Folder object.

FolderObjectName

The parameter "FolderObjectName" is used to specify the name of the instance of the Folder Object related to.

Returns:

string

The return value of the Path property is the string of path refered to the specified folder object instance.

Remarks:

FolderObjectName refers to a Folder Object.  And File and Drive objects are another possible alternate objects for the Path property.

Examples:

  • Example of using the Path property to get the path of the specified folder.

    ASP VBScript command:

    <script runat="server" language="VBScript">
    Dim fso, FolderObjectName, folderpath
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set FolderObjectName = fso.GetFolder("d:\temp")
    folderpath= FolderObjectName.Path
    Response.Write folderpath & "<br />"
    </script>

    HTML web page output

    D:\temp

  • Example of using the Path property to get the path of the specified folder.

    ASP JScript command:

    <script runat="server" language="JScript">
    var fso, FolderObjectName, folderpath;
    fso = new ActiveXObject("Scripting.FileSystemObject");
    FolderObjectName = fso.GetFolder("d:\\temp");
    folderpath = FolderObjectName.Path
    Response.Write (folderpath+ "<br />");
    </script>

    HTML web page output

    D:\temp

Previous Month  MAY  2013  Next Month
SMTWTFS
1234
567891011
12131415161718
19202122232425
262728293031

Previous Month    2010  Next Month
SMTWTFS
12345
6789101112
13141516171819
20212223242526
2728293031

Sideway BICK Blog

08/05


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