Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE

Can SilkTest create and verify directories?

Can SilkTest create and verify directories?

Creating and Verifying Folders on the Directory
 

Very often during testing there is a need to verify if a particular folder exists or to create a folder in a given directory.

The 4Test function for checking existence of a directory is:

SYS_DirExists ( sPath ) 

where sPath is full path to the directory.

The 4Test function for creating a given directory is:

SYS_MakeDir ( sPath ) 

A check can be run for the existence of the directory and create it in the case where it doesn"t.

if !(SYS_DirExists ( sPath)) SYS_MakeDir ( sPath ) 

Now consider the following situation: It is required to create a directory on the C drive. Here"s how to do it:

C:\Test\Results\May1999\ 

Substituting sPath in the above code with the string "C:\Test\Results\May1999\""would seem to be a solution. But what if the directory C:\Test\ does not exist? It will be necessary to add additional lines to the code to make sure all directories in the given path exist.

Another scenario would be to create several subdirectories in the directory "Results", say "April1999","May1999" and "June1999". We could declare a list of strings containing the subdirectories and write a loop using the above-mentioned functions, like the code shown below:

void main () [-]List of string lsDirectories = {} [] "April1999" [] "May1999" [] "June1999" 

 

DISCLAIMER:

Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
1 of 1
Last update:
‎2013-02-15 19:24
Updated by:
 
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.