Click here to Skip to main content
15,915,160 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Pls Help.....!!


public static void SaveJPGWithCompressionSetting(System.Drawing.Image image, string szFileName, long lCompression)
    {
        // ERROR: Not supported in C#: OnErrorStatement
        //goto chkErr;
        //goto chkErr onError;
        bool errOcr = false;
        if (errOcr == true)
        {
            goto chkErr;
        }
        EncoderParameters eps = new EncoderParameters(1);
        eps.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, lCompression);
        ImageCodecInfo ici = GetEncoderInfo("image/jpeg");
        image.Save(szFileName, ici, eps);
        return;
    chkErr:
        string strPageErro="Error: " +Err.Number + " " +Err.Description + "\\r\\n" + "Choose a different name for file.";
        //mbox("Error: " +Err.Number + " " +Err.Description + "\\r\\n" + "Choose a different name for file.");
        errOcr = true;
        //Resume next;

    }



Thanks...!!
Posted
Updated 13-May-10 9:17am
v2

narendrarathod wrote:
ERROR: Not supported in C#: OnErrorStatement


Which part of that is confusing you ?


narendrarathod wrote:
bool errOcr = false;
if (errOcr == true)
{
goto chkErr;
}


This is obviously idiocy. Delete it, it does nothing, and is a poorly designed construct. Use a try catch instead. This looks to me like bad VB6 that someone converted to VB.NET and you're trying to move to C# by hand. Is that right ?
 
Share this answer
 
Comments
narendrarathod 13-May-10 10:27am    
i delete it but now also same error in line

string strPageErro = "Error: " Err.Number " " Err.Description "\\r\\n" "Choose a different name for file.";
I agree with Christian, this looks like converted VB6 code.

Here's the thing:

The "Err" object still exists in VB.NET, but it DOESN'T exist in C#.

What you need to do is like Christian suggested: Wrap your code in a try/catch statement:

try
{
//Your code goes here
}
catch (Exception ex)
{
//Error caught here, now use the properties of the Exception object, e.g. Discription:
string errorDiscription = ex.Discription;
}


Good luck

Another thing: Even though it is possible in .NET; I can't think of ANY reason where you would need to use "Goto", so try to avoid that in the future... Just a tip for better programming
 
Share this answer
 
v2
So, what's your question? All you did was post some code. We can't just divine from thin air what you might want.
 
Share this answer
 
v2
please post a logical code i am not getting it, all ya did is paste some code but tell us exactly what you want in this code just like the other programmers said use try catch which is a good practice to handle error in your application...
 
Share this answer
 
v2

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