I instantiate a wxFileInputStream object giving it a filename that doesn't exist:
wxFileInputStream fizzy5(fdlg->GetPath());
At the point the wxFileInputStream object is destroyed it always throws this message box:
"Can't open file 'C:\somefilename' (error 2: the system cannot find the file specified.)"
Is there a way to not have the message box appear?
I am also wondering, what is the proper way to forcefully destroy fizzy5 when I'm done with it?
wxFileInputStream File Not Found Error
Re: wxFileInputStream File Not Found Error
Use wxLogNull. Check the docs to see how it works to avoid possible side effectsLowkus wrote:Is there a way to not have the message box appear?
Call the dtor directly? But that is somewhat unusual so perhaps it would be better to create it on heap instead of stack so you can delete it...Lowkus wrote:I am also wondering, what is the proper way to forcefully destroy fizzy5 when I'm done with it?
IMO, if possible, it would be best to use a small scope which would take care of both issues.
Code: Select all
{
wxLogNull logNo;
wxFileInputStream fizzy5(fdlg->GetPath());
// read from the stream
} // logging re-enabled and stream destroyed here