Click here to Skip to main content
15,898,538 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
try
        {
            // Grab Text From Image
            MODI.Document ModiObj = new MODI.Document();
            ModiObj.Create(ImagePath);
            ModiObj.OCR(MODI.MiLANGUAGES.miLANG_ENGLISH, true, true);

            //Retrieve the text gathered from the image
            MODI.Image ModiImageObj = (MODI.Image)ModiObj.Images[0];

            // Store Image Content in Text File
            FileStream CreateFileObj = new FileStream(HttpContext.Current.Request.PhysicalApplicationPath + @"convertedFile\OCR_File.txt", FileMode.Create);


            //save the image text in the text file 
            StreamWriter WriteFileObj = new StreamWriter(CreateFileObj);

            WriteFileObj.Write(ModiImageObj.Layout.Text);

            //WriteFileObj.Write(xyz);

            WriteFileObj.Close();

            ModiObj.Close();
        }
        catch (Exception ex)
        {
            throw new Exception(ex.Message);
        }
    }

I am getting error CS1501: No overload for method 'Close' takes '0' arguments
Posted
Updated 21-Oct-13 21:06pm
v2
Comments
Ankur\m/ 22-Oct-13 3:13am    
It's a compilation error. You class 'MODI.Document' doesn't have a close method defined which takes no input parameter. You will need to pass the required parameters to this method.
Pratik Bhuva 25-Oct-13 3:07am    
sorry for saying this but i can't stop myself from commenting,

"ModiObj.Create(ImagePath);"
Really !!! "Modi" is this famous that people are using his name in their code.
just kidding.don't take it seriouslly.

Do use 'using' statement with file operations. You don't need to explicitly call flush and close methods. They will be called automatically.
C#
try
{

// Grab Text From Image
MODI.Document ModiObj = new MODI.Document();
ModiObj.Create(ImagePath);
ModiObj.OCR(MODI.MiLANGUAGES.miLANG_ENGLISH, true, true);

//Retrieve the text gathered from the image
MODI.Image ModiImageObj = (MODI.Image)ModiObj.Images[0];

// Store Image Content in Text File
using(FileStream CreateFileObj = new FileStream(HttpContext.Current.Request.PhysicalApplicationPath + @"convertedFile\OCR_File.txt", FileMode.Create))
using(StreamWriter WriteFileObj = new StreamWriter(CreateFileObj))
{
WriteFileObj.Write(ModiImageObj.Layout.Text);

//WriteFileObj.Write(xyz);

}
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
 
Share this answer
 
It looks you have to pass the 'optional' (see here[^] :-) ) argument to the MODI.Document.Close method.

So change from
Quote:
ModiObj.Close();

to
C#
ModiObj.Close(false);

(or ModiObj.Close(true);, depending on your needs).
 
Share this answer
 
v2
This kind of error shown when you are passing different no of arguments to method that takes different no of argument.
For Ex...
C#
public void MyMethod(string name)
{
   //you have to pass one argument whenever you call this method. 
}

//You have to call it like...
MyMethod(StringValue);
//Following will give error.
MyMethod(); // error.
MyMethod(intValue) // error
MyMethod(stringValue, StringValue) // error

or you can use optional parameter in method argument
C#
public void MyMethod(string name="DefaultValue")
{
   //Here if you don't pass any argument then it will take default value and it won't throw error any more
}


sorry for saying this but i can't stop myself from commenting,

C#
"ModiObj.Create(ImagePath);"

Really !!! Modi is this famous that people are using his name in their code.

just kidding.don't take it seriously.

Hope This Help
-----------------
Pratik Bhuva
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900