Sometimes one needs to produce a list of files in a directory hierarchy. Here is one possible solution that uses a recursive subroutine.
Tag Archive: Folders
Mar 31 2008
Determine the Day of the Week
Dot.Net Framework provides several classes for dates and times. the primary class is the System.DateTime. The class Represents an instant in time, typically expressed as a date and time of day. The System.DayOfWeek enumeration Specifies the day of the week. Friday Indicates Friday. Monday Indicates Monday. Saturday Indicates Saturday. Sunday Indicates Sunday. Thursday Indicates Thursday. …
Mar 31 2008
Determine the Size of a Folder
the WMI class Win32_Directory and noticed the property FileSize. Based on that, you might think, “Well, obviously I could just write a WMI script to get the folder size.” In turn you might write a script very similar to this one, which tries to determine the size of the folder C:\Scripts on the computer atl-ws-01: …
Mar 31 2008
List all Files and Directories in a Specific Directory
Dir displays a list of files and subdirectories in a directory. DIR is a command used to display a list of files and subdirectories in a directory.. Windows 2000 and Windows XP syntax DIR [drive:][path][filename] [/A[[:]attributes]] [/B] [/C] [/D] [/L] [/N] [/O[[:]sortorder]] [/P] [/Q] [/S] [/T[[:]timefield]] [/W] [/X] [/4] [drive:][path][filename] Specifies drive, directory, and/or files …
Mar 31 2008
List only directories in a specific directory
Dir displays a list of files and subdirectories in a directory. DIR is a command used to display a list of files and subdirectories in a directory.. Windows 2000 and Windows XP syntax DIR [drive:][path][filename] [/A[[:]attributes]] [/B] [/C] [/D] [/L] [/N] [/O[[:]sortorder]] [/P] [/Q] [/S] [/T[[:]timefield]] [/W] [/X] [/4] [drive:][path][filename] Specifies …
Mar 31 2008
List only Files and Folders in a Specific Directory and Sub-Directory
Dir displays a list of files and subdirectories in a directory. DIR is a command used to display a list of files and subdirectories in a directory.. Windows 2000 and Windows XP syntax DIR [drive:][path][filename] [/A[[:]attributes]] [/B] [/C] [/D] [/L] [/N] [/O[[:]sortorder]] [/P] [/Q] [/S] [/T[[:]timefield]] [/W] [/X] [/4] [drive:][path][filename] Specifies drive, directory, and/or files …
Mar 31 2008
Determine if a Folder Exists
System.IO.DirectoryInfoclass exposes instance methods for creating, moving, and enumerating through directories and subdirectories. The example verifies if a directory exists. The dirInfo is built using the directory name constructor. Is a very good practice to verify if a directory exists, before accessing the directory. Dim dirInfo, dirName dirName = “C:\LOG” Set dirInfo = DotNetFactory.CreateInstance( “System.IO.DirectoryInfo”,, …
Mar 31 2008
Copy/Move all Contents of a Directory
System.IO.DirectoryInfo class exposes instance methods for creating, moving, and enumerating through directories and subdirectories. System.IO.File Provides static methods for the creation, copying, deletion, moving, and opening of files. Public Sub CopyDirectory( ByVal sourceDirectory, ByVal targetDirectory ) Dim srcInfo, trgInfo, sysFile, sourceFiles, sourceDirectories Dim i, j, fileItem, folderItem Set srcInfo = DotNetFactory.CreateInstance( “System.IO.DirectoryInfo”,, sourceDirectory ) Set …
Mar 31 2008
Create a Directory Listing
The following code example shows how to use the I/O classes to create a listing of all files with the extension “.exe” in a directory. The output data is inserted to the local data sheet and also print to the QTP log. Option Explicit Dim pathStr Dim fileInfo, dirInfo, ioDir, dirsInfo Dim nFile, nLength DataTable.LocalSheet.Addparameter …
Mar 31 2008
Rename or Move a Directory
The following code example shows how to use the I/O classes to create a listing of all files with the extension “.exe” in a directory. The output data is inserted to the local data sheet and also printed to the QTP log. Option Explicit Dim pathStr Dim fileInfo, dirInfo, ioDir, dirsInfo Dim nFile, nLength DataTable.LocalSheet.Addparameter …



Recent Comments