Search code examples
c#pathaccess-deniedfile-not-foundabbyy

Error File path denied, but the file is in the folder(One time success other error) C#


I want to apply OCR ABBYY with 4 photos at same time in C# (I have the function for this conversion).

1) I have file Identite.jpg (image source).

2) I have an executable file: Cutting.exe, which cuts Identite.jpg into 4 parts: Prenom.jpg, nom.jpg, Date.jpg and numcin.jpg.

3) Then, I apply the function of OCR to these 4 files.

Sometimes I have a successful result, but other times I get the following error:

D:\CINPROCESSING\Prenom.jpg FileNotFound

However, this file is located here!!

I have tested this by manually executing the file Cutting.exe. When I execute my C# application, and the result always successful - yielding the 4 files.

But when the function of OCR comes, the FileNotFound error appears (even though this file is in the folder)!

I have even executed the file in C# with Full Access: administrator:

Process.Start(@"D:\Cutting.exe");
        ProcessStartInfo kk = new ProcessStartInfo();
        kk.Verb = "runas";

I also tried adding in my application the element: app.manifest, and I modified the requestedExecutionLevel with 'requireAdministrator':

<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />

Always same problem! Please, how can I fix it?

Thanks,


Solution

  • I tested if the file is existing or not ... it is not existing .. I have found the solution: I added :

    Thread.Sleep (3000);

    between Step 2) and Step 3)

    And now it works well

    Very thanks,