タイトルが説明しているように、続行する前にディレクトリが存在するかどうかを確認するプログラムがあります。
そして、チェックが行われると、ディレクトリが存在するときに存在しないと言われます!
ディレクトリ パスを格納するコードは次のとおりです。
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;
}
そして、チェックを実行するためのコード:
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.");
}
C:\Windows フォルダーが存在するかどうかを確認するなど、いくつかのバリエーションでデバッグを試みましたが、それでもエラーが発生します...
コードに何か問題がありますか、または .Exists メソッドの理解に問題がありますか?
ありがとう!