As title explains, I have a program that checks if a directory exists before continuing.
And when the check is made it, it says the directory doesn't exist when it does!
Here's the code for storing the directory path:
string currentDirectory = Path.GetDirectoryName(Application.ExecutablePath);
Console.WriteLine("----" + currentDirectory.ToString());
string tesseractPath = Path.Combine(currentDirectory, @"..\..\..\tesseract");
_wrapper = new AsyncTesseractWrapper(tesseractPath);
public TesseractWrapper(string programLoc)
{
DirectoryInfo dinfo = new DirectoryInfo(programLoc);
//DirectoryInfo dinfo = new DirectoryInfo("C:\\Windows");
ValidateTesseractDirectory(dinfo);
_tesseractLocation = dinfo.FullName;
}
And the code for performing the check:
private void ValidateTesseractDirectory(DirectoryInfo dinfo)
{
if (!dinfo.Exists)
throw new ArgumentException("Specified program directory must exist.");
FileInfo[] files;
files = dinfo.GetFiles(_tessExe);
if (files.Length != 1)
throw new ArgumentException("Specified program directory must contain tesseract.exe.");
}
I've tried debugging with several variations, like checking if the C:\Windows folder exists and it's still giving me an error...
Is there something wrong with the code, or my understanding of the .Exists method... ?
Thanks!