8: Files and Folders related Functions

Files and Folders related Functions

VBScript Runtime Properties

Like the objects in the WSH core object model, VBScript runtime objects provide an extensive supply of properties. You can use the properties to view or change numerous file system attributes. These properties are listed here. 
·         AtEndOfLine. Returns a value of either true or false depending on whether the file pointer precedes the TextStream file’s end-of-line marker.
·         AtEndOfStream. Returns a value of either true or false depending on whether the end of a TextStream file has been reached.
·         Attributes. Retrieves or sets file and folder attributes.
·         AvailableSpace. Retrieves the amount of free space available on a drive.
·         Column. Retrieves the current column position within a
TextStream
file.

·         CompareMode. Retrieves or sets the comparison mode used to compare a Dictionary object’s string keys.
·         Count. Returns a count of the items in a collection or Dictionary object.
·         DateCreated. Returns a file or folder’s creation date and time.
·         DateLastAccessed. Returns the date and time that a file or folder was last accessed.
·         DateLastModified. Returns the date and time that a file or folder was last modified.
·         Drive. Returns the drive letter representing the drive where a file or folder is stored.
·         DriveLetter. Returns a drive’s drive letter.
·         Drives. Creates a Drives collection representing the computer’s Drive objects.
·         DriveType. Returns a value indicating a drive’s type.
·         Files. Creates a Files collection representing the File objects stored inside a folder.
·         FileSystem. Returns the file system type implemented on a drive.
·         FreeSpace. Returns the amount of free space available to the user on a drive.
·         IsReady. Returns a value of either true or false depending on whether a drive is available.
·         IsRootFolder. Returns a value of either true or false identifying whether a folder is the root folder.
·         Item. Retrieves or sets an item based on the specified Dictionary object key.
·         Key. Sets a Dictionary object key.
·         Line. Returns the current line number in the TextStream file.
·         Name. Retrieves or sets a file or folder’s name.
·         ParentFolder. Retrieves a file or folder’s parent folder object.
·         Path. Retrieves the path associated with a file, folder, or drive.
·         RootFolder. Retrieves the Folder object associated with the root folder on the specified drive.
·         SerialNumber. Retrieves a disk volume’s serial number.
·         ShareName. Retrieves a network drive’s share name.
·         ShortName. Retrieves a file’s or folder’s 8.3 character short name.
·         ShortPath. Retrieves the short path associated with a file’s or folder’s 8.3 character name.
·         Size. Retrieves a file’s or folder’s byte size.
·         SubFolders. Establishes a Folders collection consisting of all the folders located inside a specified folder.
·         TotalSize. Returns the total number of bytes left on a drive.
·         Type. Retrieves information about a file’s or folder’s type.
·         VolumeName. Retrieves or sets a drive’s volume name.

VBScript Runtime Methods

The methods that belong to the VBScript runtime objects are listed here.

VBScript Run-time Methods
·         Add (Dictionary). Adds a key and item pair to a Dictionary object.
·         Add (Folders). Adds a Folder to a collection.
·         BuildPath. Appends a name to the path.
·         Close. Closes an open TextStream file.
·         Copy. Copies a file or folder.
·         CopyFile. Copies one or more files.
·         CopyFolder. Recursively copies a folder.
·         CreateFolder. Creates a new folder.
·         CreateTextFile. Creates a file and a TextStream object that can be used to read and write to the file.
·         Delete. Deletes a file or folder.
·         DeleteFile. Deletes a file.
·         DeleteFolder. Deletes a folder’s contents.
·         DriveExists. Returns either true or false depending on the existence of a drive.
·         Exists. Returns either true or false depending on whether a key exists in a Dictionary object.
·         FileExists. Returns either true or false depending on whether a file can be found.
·         FolderExists. Returns a value of true or false depending on whether a folder can be found.
·         GetAbsolutePathName. Returns a complete path name.
·         GetBaseName. Retrieves a filename less its file extension.
·         GetDrive. Returns the Drive object associated with the drive in the specified path.
·         GetDriveName. Retrieves the name of a drive.
·         GetExtensionName. Retrieves a file’s extension.
·         GetFile. Retrieves a File object.
·         GetFileName. Retrieves the last filename or folder of the specified path.
·         GetFileVersion. Retrieves a file’s version number.
·         GetFolder. Retrieves the Folder object associated with the folder in the specified path.
·         GetParentFolderName. Retrieves the name of the parent folder.
·         GetSpecialFolder. Retrieves a special folder’s name.
·         GetTempName. Retrieves the name of a temporary file or folder.
·         Items. Returns an array containing the items in a Dictionary object.
·         Keys. Returns an array containing the keys in a Dictionary object.
·         Move. Moves a file or folder.
·         MoveFile. Moves one or more files.
·         MoveFolder. Moves one or more folders.
·         OpenAsTextStream. Opens a file and returns a TextStream object that can be used to reference the file.
·         OpenTextFile. Opens a file and returns a TextStream object that can be used to reference the file.
·         Read. Returns a string containing x number of characters from a TextStream file.
·         ReadAll. Reads the whole TextStream file and returns its contents.
·         ReadLine. Reads a line in a TextStream file.
·         Remove. Deletes a Dictionary object’s key, item pair.
·         Skip. Skips x number of character positions when processing a TextStream file.
·         SkipLine. Skips a line when processing a TextStream file.
·         Write. Places a string in the TextStream file.
·         WriteBlankLines. Writes x number of newline characters to the TextStream file.
·         WriteLine. Writes a string in the TextStream file

Next Step – File Scripting

Advertisement

About kuldeep kumar

i am a software engineer and working in an MNC.

Posted on February 5, 2008, in Learn VBScript for QTP (Descriptive Programming). Bookmark the permalink. 2 Comments.

  1. Hi Kuldeep,
    I appreciate your vbscript for QTP lessons. I am at 8. Files and Folders related functions and am wondering as to how these at run-time properties and run-time methods need to be used. Should i try out some examples or just read thru them without trying to memorize them?

  1. Pingback: 7:Pop-Up Dialogs « KR Testing Solutions

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 39 other followers