R. E. Cook
RunningShoes Library for WinRunner
Custom WinRunner Functions
and Utilities, to Your Specs
A Random Collection of WinRunner Solutions
Creating DLLs for WinRunner
(Mercury Interactive's Worldwide Users Conference 2000)
R. E. Cook
Delete a folder and all files in the folder
Functions: FolderListFiles(), FolderDelete(), FileDelete(),
Deleting a folder full of files is simple with RunningShoes. Delete all files in
the folder, then delete the folder itself. The easy way is to capture an array
with all of the filenames, then loop through the array, deleting each file after
turning off any attributes that might prevent the deletion. When the folder is
empty, delete it too.
## Define the path to the folder.
folder = "c:\\FilesToBeDeleted\\";
## Capture an array of files in the folder.
rc = FolderListFiles(folder, file_arr);
## Display an error message if the function fails.
if(rc != E_OK)
message = "Error capturing filenames: " &
## Delete all files in the array.
for(subscript in file_arr)
## Append the filename to the path.
current_file = folder & file_arr[subscript];
## Turn off all attributes so the file can be deleted.
rc = FileSetAttributes(current_file, FILE_ATTRIBUTE_NORMAL);
## Delete the file.
rc = FileDelete(current_file);
## Delete the folder.
rc = FolderDelete(folder);
Updated 17 January 2005