public void executarEvento(object sender, FileSystemEventArgs e) { while (Ocr.IsFileLocked(e.FullPath)) { } File.AppendAllText("logprocessado.txt", e.FullPath); executar(e.FullPath); }
public void executar(string CAMINHO) { try { criarpastas(); string str1 = ConfigurationManager.AppSettings["pastaEntradaTemp"].ToString(); var item = CAMINHO; if (Path.GetExtension(item).ToUpper() == ".TIFF" || Path.GetExtension(item).ToUpper() == ".TIF" || Path.GetExtension(item).ToUpper() == ".PDF") { if (!Ocr.IsFileLocked(item)) { if (File.Exists(str1 + @"" + Path.GetFileName(item))) { File.Delete(str1 + @"" + Path.GetFileName(item)); } File.Move(item, string.Concat(str1, "\\", Path.GetFileName(item))); } } item = string.Concat(str1, "\\", Path.GetFileName(item)); if (Path.GetExtension(item).ToUpper() == ".TIFF" || Path.GetExtension(item).ToUpper() == ".TIF" || Path.GetExtension(item).ToUpper() == ".PDF") { try { executarOcr(item); } catch (Exception ex) { var logpath = ConfigurationManager.AppSettings["PastaDestinoLog"].ToString(); File.AppendAllText(logpath + @"\" + "log.txt", ex.ToString()); } } } catch (Exception ex) { var logpath = ConfigurationManager.AppSettings["PastaDestinoLog"].ToString(); File.AppendAllText(logpath + @"\" + "log.txt", ex.ToString()); // Console.WriteLine(ex.Message); } }