C
Claire
The following is a self calling function to search directories for an
instance of a particular executable. VS .net 2003.
On one pass through, Im getting an error DirectoryNotFoundException when the
Directory.GetFiles(dir, "pocketvibrapro.exe") line is called.
At that stage the dir is "\Program Files\McmCollector ". This is the
directory from where my active application is being debugged.
I've also tried using dir.trim in case the final space char caused a
problem.
Any ideas?
public static string SearchDirectory(string dir)
{
string str2;
// Query for exe
string[] str = Directory.GetFiles(dir, "pocketvibrapro.exe");
// If found return directory
if (str.Length > 0)
return dir;
// Read subdirectories
str = Directory.GetDirectories(dir);
// search subdirectories
for (int nCount = 0; nCount < str.Length; nCount++)
{
str2 = SearchDirectory(str[nCount]);
if (str2 != "")
return str[nCount];
}
return "";
}
instance of a particular executable. VS .net 2003.
On one pass through, Im getting an error DirectoryNotFoundException when the
Directory.GetFiles(dir, "pocketvibrapro.exe") line is called.
At that stage the dir is "\Program Files\McmCollector ". This is the
directory from where my active application is being debugged.
I've also tried using dir.trim in case the final space char caused a
problem.
Any ideas?
public static string SearchDirectory(string dir)
{
string str2;
// Query for exe
string[] str = Directory.GetFiles(dir, "pocketvibrapro.exe");
// If found return directory
if (str.Length > 0)
return dir;
// Read subdirectories
str = Directory.GetDirectories(dir);
// search subdirectories
for (int nCount = 0; nCount < str.Length; nCount++)
{
str2 = SearchDirectory(str[nCount]);
if (str2 != "")
return str[nCount];
}
return "";
}