R. E. Cook
Home 
Contact Us 

Dr. Cook
Resume 

RunningShoes Library for WinRunner 
RunningShoes 

Custom WinRunner Functions 
and Utilities,
to Your Specs
Custom 

A Random Collection of WinRunner Solutions
Solutions 

Creating DLLs for WinRunner 
"DLLs Demystified" 
(Mercury Interactive's Worldwide Users Conference 2000)

R. E. Cook Consulting

 


Extract the components of a path

Functions: FolderListFiles(), FolderDelete(), FileDelete(), FileSetAttributes()


RunningShoes makes it easy to decompose a full path into its constituent parts (drive, path, filename and extension). The same code works with both letter and UNC drives, and full or partial paths.


Letter drive

## Define the path with filename.
file_with_path = "c:\\Program Files\\Mercury Interactive\\WinRunner\\arch\\wrun.exe";

## Extract the drive: "c:"
rc = PathGetDrive(file_with_path, drive);

## Extract the path: "\\Program Files\\Mercury Interactive\\WinRunner\\arch\\"
rc = PathGetPath(file_with_path, path);  

## Extract the filename: "wrun"
rc = PathGetFileName(file_with_path, filename); 

## Extract the extension: ".exe"
rc = PathGetExt(file_with_path, extension);


UNC drive

## Define the path with filename.
file_with_path = "\\\\Aphrodite\\Public\\WinRunner\\Scripts\\NewTest\\script";

## Extract the drive: "\\\\Aphrodite\\Public"
rc = PathGetDrive(file_with_path, drive);

## Extract the path: "\\WinRunner\\Scripts\\NewTest\\"
rc = PathGetPath(file_with_path, path);  

## Extract the filename: "script"
rc = PathGetFileName(file_with_path, filename); 

## Extract the extension: ""
rc = PathGetExt(file_with_path, extension);

 


Updated 17 January 2005



Top of  This Page | R. E. Cook Home Page

Copyright R. E. Cook Consulting, 2000 - 2011.
All rights reserved.

The site is designed to look best when viewed with Internet Explorer 5.0 - 8.0. Results with other browsers will probably deviate from what is intended.

NOTE: This website refers to registered trademarks and service marks that are owned by other companies, including Mercury Interactive, WinRunner, TestDirector, TSL, Microsoft, Windows.