Make sure inputs not null

This commit is contained in:
Jaex 2018-08-11 16:33:50 +03:00
parent 7196c9a6a1
commit 3eade4e4cc

View file

@ -1077,7 +1077,7 @@ public static void OCRImage(string filePath)
}
}
public static void OCRImage(Stream stream, string fileName, string filePath = "")
public static void OCRImage(Stream stream, string fileName, string filePath = null)
{
if (stream != null)
{
@ -1086,9 +1086,11 @@ public static void OCRImage(Stream stream, string fileName, string filePath = ""
form.Language = Program.Settings.OCRLanguage;
form.ShowDialog();
Program.Settings.OCRLanguage = form.Language;
if (filePath != "")
if (!string.IsNullOrEmpty(form.Result) && !string.IsNullOrEmpty(filePath))
{
File.WriteAllText(Path.ChangeExtension(filePath, ".txt"), form.Result, Encoding.UTF8);
string textPath = Path.ChangeExtension(filePath, "txt");
File.WriteAllText(textPath, form.Result, Encoding.UTF8);
}
}
}