Login   /   Register
Folders

Rename or move a directory

March 31st, 2008 by daniva
     0 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 5
Loading ... Loading ...

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 printeg to the QTP log.

Create a Directory Listing

March 31st, 2008 by daniva
     0 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 5
Loading ... Loading ...

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 printeg to the QTP log.

Copy/Move all Contents of a Directory

March 31st, 2008 by daniva
     0 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 5
Loading ... Loading ...

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.

Determine if a folder exists

March 31st, 2008 by daniva
     0 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 5
Loading ... Loading ...

System.IO.DirectoryInfo class exposes instance methods for creating, moving, and enumerating through directories and subdirectories.

List only Files and Folders in a Specific Directory and Sub-Directory

March 31st, 2008 by daniva
     0 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 5
Loading ... Loading ...

the example list all folders under QTP installation folder. optionally you can load the output to an array, id you need to iterate the list.

Lists only directories in a specific directory

March 31st, 2008 by daniva
     0 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 5
Loading ... Loading ...

the example list all folders under C:\Automation. optionally you can load the output to an array, id you need to iterate the list.

List all Files and Directories in a Specific Directory

March 31st, 2008 by daniva
     0 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 5
Loading ... Loading ...

Dir displays a list of files and subdirectories in a directory.

Determine the size of a folder

March 31st, 2008 by daniva
     2 votes, average: 4.5 out of 52 votes, average: 4.5 out of 52 votes, average: 4.5 out of 52 votes, average: 4.5 out of 52 votes, average: 4.5 out of 5
Loading ... Loading ...

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:

Determine if a Folder Has Any Files with a Specific File Extension

March 31st, 2008 by daniva
     0 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 5
Loading ... Loading ...

All we have to do is write a WMI query that includes the path of the folder we want to check as well as the file extension we’re checking for. For example, this script retrieves a collection of all the .bak files found in the C:\Logs folder: