Sideway BICK BlogSideway BICK BLOG from Sideway

A Sideway to Sideway Home

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

Script, Scripting Language, VBScript elements, Server-Side VBScript Object Element FileSystemObject Method

VBScript Methods of FSO Object

Some typical predefined Elements are.

  • FSO Object:
    • BuildPath Method
    • CopyFile Method
    • CopyFolder Method
    • CreateFolder Method ≡ Folder Object
    • CreateTextFile Method
    • DeleteFile Method
    • DeleteFolder Method
    • DriveExists Method
    • FileExists Method
    • FolderExists Method
    • GetAbsolutePathName Method
    • GetBaseName Method
    • GetDrive Method ≡ Drive Object
    • GetDriveName Method
    • GetExtensionName Method
    • GetFile Method ≡ File Object
    • GetFileVersion Method
    • GetFileName Method
    • GetFolder Method ≡ Folder object
    • GetParentFolderName Method
    • GetSpecialFolder Method ≡ Folder object
    • GetStandardStream Method ≡ TextStream object
    • GetTempName Method
    • MoveFile Method
    • MoveFolder Method
    • OpenTextFile Method

GetAbsolutePathName Method

last updated 12/14/2017

is to return a complete and unambiguous absolute path name from given pathspec path.

Syntax

fsoobjvar.GetAbsolutePathName(pathspec)

Argument

fsoobjvarRequired. to specify the associated Object instance reference.GetAbsolutePathNameRequired Keyword. to specify the Method of associated Object.folderspecRequired. Path specification to change to a complete and unambiguous path.

Remarks

  • A path is complete and unambiguous if it provides a complete reference from the root of the specified drive. A complete path can only end with a path separator character (\) if it specifies the root folder of a mapped drive.
  • Assuming the current directory is c:\mydocuments\reports, the following table illustrates the behavior of the GetAbsolutePathName method.

    CompareMode Setting

    pathspec (VBScript)pathspec (JScript)Returned path"c:""c:""c:\mydocuments\reports""c:..""c:..""c:\mydocuments""c:\""c:\\""c:\""c:*.*\may97""c:*.*\\may97""c:\mydocuments\reports\*.*\may97""region1""region1""c:\mydocuments\reports\region1""c:\..\..\mydocuments""c:\\..\\..\\mydocuments""c:\mydocuments"

Applied to

FileSystemObject Object

GetBaseName Method

last updated 12/14/2017

is to return a string containing the base name of the last component, less any file extension, in given path.

Syntax

fsoobjvar.GetBaseName(path)

Argument

fsoobjvarRequired. to specify the associated Object instance reference.GetBaseNameRequired Keyword. to specify the Method of associated Object.pathRequired. The path specification for the component whose base name is to be returned.

Remarks

  • The GetBaseName method returns a zero-length string ("") if no component matches the path argument.
  • The GetBaseName method works only on the provided path string. It does not attempt to resolve the path, nor does it check for the existence of the specified path.

Applied to

FileSystemObject Object

GetDrive Method

last updated 12/14/2017

is to return a Drive object according to the drive component of the given drivespec.

Syntax

fsoobjvar.GetDrive ( drivespec )

Argument

fsoobjvarRequired. to specify the associated Object instance reference.GetDriveRequired Keyword. to specify the Method of associated Object.drivespecRequired. The drivespec argument can be a drive letter (c), a drive letter with a colon appended (c:), a drive letter with a colon and path separator appended (c:\), or any network share specification (\\computer2\share1).

Remarks

  • For network shares, a check is made to ensure that the share exists.
  • An error occurs if drivespec does not conform to one of the accepted forms or does not exist.
  • To call the GetDrive method on a normal path string, use the following sequence to get a string that is suitable for use as drivespec:
    DriveSpec = GetDriveName(GetAbsolutePathName(Path))

Applied to

FileSystemObject Object

GetDriveName Method

last updated 12/14/2017

is to return a string containing the drive name of drive component of the given path.

Syntax

fsoobjvar.GetDriveName(path)

Argument

fsoobjvarRequired. to specify the associated Object instance reference.GetDriveNameRequired Keyword. to specify the Method of associated Object.pathRequired. The path specification for the component whose drive name is to be returned.

Remarks

  • The GetDriveName method returns a zero-length string ("") if the drive can't be determined.
  • The GetDriveName method works only on the provided path string. It does not attempt to resolve the path, nor does it check for the existence of the specified path.

Applied to

FileSystemObject Object

GetExtensionName Method

last updated 12/14/2017

is to return the file extension of the last file component of the given path

Syntax

fsoobjvar.GetExtensionName(path)

Argument

fsoobjvarRequired. to specify the associated Object instance reference.GetExtensionNameRequired Keyword. to specify the Method of associated Object.pathRequired. The path of the component whose extension is to be returned.

Remarks

  • For network drives, the root directory (\) is considered to be a component.
  • This method returns an empty string ("") if the file doe not exist.

Applied to

FileSystemObject Object

GetFile Method

last updated 12/14/2017

is to return a File Object according to the file of given filespec path.

Syntax

fsoobjvar.GetFile(filespec)

Argument

fsoobjvarRequired. to specify the associated Object instance reference.GetFileRequired Keyword. to specify the Method of associated Object.filespecRequired. The filespec is the path (absolute or relative) to a specific file.

Remarks

  • An error occurs if the specified file does not exist.
  • The GetFile method does not support the use of wildcard characters, such as ? or *.

Applied to

FileSystemObject Object

GetFileVersion Method

last updated 12/14/2017

is to return the version number of a file component according to the last component of given pathspec path.

Syntax

fsoobjvar.GetFileVersion(pathspec)

Argument

fsoobjvarRequired. to specify the associated Object instance reference.GetFileVersionRequired Keyword. to specify the Method of associated Object.pathspecRequired. The path (absolute or relative) to a specific file.

Remarks

  • The GetFileVersion method returns a zero-length string ("") if pathspec does not end with the named component.
  • The GetFileVersion method works only on the provided path string. It does not attempt to resolve the path, nor does it check for the existence of the specified path.

Applied to

FileSystemObject Object

GetFileName Method

last updated 12/14/2017

is to return the file namer of a file component according to the last component of given pathspec path.

Syntax

fsoobjvar.GetFileName(pathspec)

Argument

fsoobjvarRequired. to specify the associated Object instance reference.GetFileNameRequired Keyword. to specify the Method of associated Object.pathspecRequired. The path (absolute or relative) to a specific file.

Remarks

  • The GetFileName method returns a zero-length string ("") if pathspec does not end with a file name.
  • The GetFileName method works only on the provided path string. It does not attempt to resolve the path, nor does it check for the existence of the specified path.

Applied to

FileSystemObject Object

GetFolder Method

last updated 12/14/2017

is to return a Folder object according to the given folderspec path.

Syntax

fsoobjvar.GetFolder(folderspec)

Argument

fsoobjvarRequired. to specify the associated Object instance reference.GetFolderRequired Keyword. to specify the Method of associated Object.folderspecRequired. The folderspec is the path (absolute or relative) to a specific folder.

Remarks

  • An error occurs if the specified folder does not exist.

Applied to

FileSystemObject Object

GetParentFolderName Method

last updated 12/14/2017

is to return a string containing the name of the parent folder of the last component in a given path.

Syntax

fsoobjvar.GetParentFolderName(path)

Argument

fsoobjvarRequired. to specify the associated Object instance reference.GetParentFolderNameRequired Keyword. to specify the Method of associated Object.pathRequired. The path specification for the component whose parent folder name is to be returned.

Remarks

  • The GetParentFolderName method returns the full path up to and including the name of the parent folder.
  • The GetParentFolderName method returns a zero-length string ("") if there is no parent folder for the component specified in the path argument.
  • The GetParentFolderName method works only on the provided path string. It does not attempt to resolve the path, nor does it check for the existence of the specified path.

Applied to

FileSystemObject Object

GetSpecialFolder Method

last updated 12/14/2017

is to return a special Folder Object according to the given folderspec.

Syntax

fsoobjvar.GetSpecialFolder(folderspec)

Argument

fsoobjvarRequired. to specify the associated Object instance reference.GetSpecialFolderRequired Keyword. to specify the Method of associated Object.folderspecRequired Setting. The name of the special folder to be returned. Can be any of the constants shown in the Settings section.

Settings

folderspec argument:

ConstantValueDescriptionWindowsFolder0The Windows folder contains files installed by the Windows operating system.SystemFolder1The System folder contains libraries, fonts, and device drivers.TemporaryFolder2The Temp folder is used to store temporary files. Its path is found in the TMP environment variable.

Applied to

FileSystemObject Object

GetStandardStream Method

last updated 12/14/2017

is to return a standard TextStream Object according to the given standardStreamType setting and specified optional unicode setting.

Syntax

fsoobjvar.GetStandardStream(standardStreamType [, unicode ])

Argument

fsoobjvarRequired. to specify the associated Object instance reference.GetStandardStreamRequired Keyword. to specify the Method of associated Object.standardStreamTypeRequired. Can be one of three constants: StdErr, StdIn, or StdOut.unicodeOptional. Boolean value that indicates whether the file is created as a Unicode or ASCII file. The value is true if the file is created as a Unicode file, false if it is created as an ASCII file. If omitted, an ASCII file is assumed.

Settings

standardStreamType argument:

ConstantValueDescriptionStdIn0Returns a TextStream object corresponding to the standard input stream.StdOut1Returns a TextStream object corresponding to the standard output stream.StdErr2Returns a TextStream object corresponding to the standard error stream.

Applied to

FileSystemObject Object

GetTempName Method

last updated 12/14/2017

is to generate and return a randomly generated temporary file or folder name for performing operations that require a temporary file or folder.

Syntax

fsoobjvar.GetTempName ( )

Argument

fsoobjvarRequired. to specify the associated Object instance reference.GetTempNameRequired Keyword. to specify the Method of associated Object.

Remarks

  • The optional object is always the name of a FileSystemObject.
  • The GetTempName method does not create a file. It provides only a temporary file name that can be used with CreateTextFile to create a file.

Applied to

FileSystemObject Object
Optional Element, Content Occurrence Character, Choice or sequence:(…)+one or more(…)*zero or more(…)?zero or one times(…)exactly once[…]optional(… | …)or( … & …)and( …, … )sequence⋯=⋯assign to⋯.⋯dot notation(+)include(-)exclude

Sideway BICK Blog

24/05


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