常规讨论 How to use MODI in ASP.NET Web application

  • 28 mai 2012 18:15
     
      Are cod

    I have a web application implemented in ASP.NET 4. I'm attempting to include MODI OCR in the application.

    Everything works fine when an absolute path of the image is passed to the OCR engine (like c:\Users...\test.jpg)

    but when I use relative path (like ~/Images/test.jpg), I get an unspecified error at the doc.Create(path) line. (the exception is COMException)

    Here is the code:

    MODI.Document doc = new MODI.Document(); 
     
    string path = @"~/Images/OCRPIC.png"; /*here when I replace this path with an absolute path I get no errors*/
     
    doc.Create(path); 
    doc.OCR(MiLANGUAGES.miLANG_ENGLISH, true, true); 
     
    foreach (MODI.Image image in doc.Images) 
        TextBox1.Text += image.Layout.Text + "\n"; 
    doc.Close(); 
    

    I appreciate any help or reference,

    Thanks,

Toate mesajele

  • 11 iunie 2012 07:28
     
     

    Hi yazanpro,

    Based on my knowledge, using relative path works when the file is imported as part of the resources file. Two workarounds occur to me: 1. Import the image as resources file. 2. Get the current path and combine it with the relative path to get the absolute file path.

    For more issues about asp.net, you may try to ask them at:

    http://forums.asp.net/