Microsoft KB Archive/84835

= Microsoft Knowledge Base =

How to Detect Subdirectories with Test Basic EXISTS Function
Last reviewed: October 19, 1994

Article ID: Q84835

The information in this article applies to:

- Microsoft Test for Windows, version 1.0

SUMMARY
There is no built-in function in Test Basic to detect whether or not a subdirectory exists. However, if you know what subdirectories might exist, you can check for the NUL file in a given subdirectory using the EXISTS function. This method works consistently only on local subdirectories, and may not work correctly for drives accessed through a network.

This information applies to Microsoft Test for Windows version 1.0.

MORE INFORMATION
The following code checks to see if the subdirectory \DOS exists by checking for the existence of the NUL file. (The NUL file is created when a subdirectory is created, and is subsequently present in all MS-DOS subdirectories.)

If EXISTS (&quot;C:\DOS\NUL&quot;) Then Print &quot;Subdirectory exists.&quot; Else Print &quot;Subdirectory does not exist.&quot; End If To check for the presence of other subdirectories, put each name into the path used with the EXISTS function. For example, to check for the presence of a subdirectory named TEMP, you would use the following:

If EXISTS (&quot;C:\TEMP\NUL&quot;) Then... Because this method requires the name of the subdirectory to be checked, it will not work if the subdirectory names are not known. This method works on all local MS-DOS subdirectories, and may work sporadically on network subdirectories.