473,407 Members | 2,320 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

MessageBox && FileIO Question

Below an example from "Windows Forms Programming with C#", by Erik Brown
(Manning) p. 228. According to me the example is wrong. The message box does
not get activated when an erroneous file name is entered. Could someone
indicate the error and suggest alternative code to make this example work?
Patrick
private void menuSave_Click(object sender, System.EventArgs e)
{
if (_album.FileName == null)
{
// Need to select an album file
menuSaveAs_Click(sender, e);
}
else
{
try
{
// Save the album in the current file
_album.Save();
_bAlbumChanged = false;
}
catch (Exception ex)
{
string msg = "Unable to save file {0}"
+ " - {1}\nWould you like to save"
+ " the album in an alternate file?";
DialogResult result = MessageBox.Show(this,
String.Format(msg, _album.FileName, ex.Message),
"Save Album Error",
MessageBoxButtons.YesNo,
MessageBoxIcon.Error,
MessageBoxDefaultButton.Button2);
if (result == DialogResult.Yes)
{
menuSaveAs_Click(sender, e);
}
}
}
}


Nov 15 '05 #1
0 1355

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

192
by: Kwan Ting | last post by:
The_Sage, I see you've gotten yourself a twin asking for program in comp.lang.c++ . http://groups.google.co.uk/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&th=45cd1b289c71c33c&rnum=1 If you the oh so mighty...
2
by: TonyM | last post by:
Q: Is there a good way to overcome this apparent bug without modifying the mfc code? ___________________________________ Info: Although it is NOT a good idea, I seemed to have perhaps located a...
1
by: MadCrazyNewbie | last post by:
Hey Group, Hope you all well? Wonder if somebody could possibly help me? At the Mo I use the following code to Print a Crystal Report: rptForm.Text = "Excellence.Net - Fax`s" 'Set the...
7
by: MadCrazyNewbie | last post by:
Hey Group, Sorry to be a pain again but i have the following code: If MessageBox.Show("Are Your Sure You Want To Send This Email?", "Are Your Sure You Want To Send This Email?",...
5
by: roberto | last post by:
Hi at all i have a web application (in vb.net), and i want to use a message box control like System.Windows.Forms.MessageBox control, to show simple messages . I used this but vb.net said me an...
2
by: AMP | last post by:
I want to display a message box when a form displays:Copyright,blah,blah,blah. But I can seam to know where to put it.I tried form load, initialize component. Where does it go? Thanks Mike
1
by: Necromis | last post by:
I am trying to figure out a way to change the below code to store data in a multidemensional array rather than a listbox. The reason being is I need to be able to pull each "currentrow" and...
2
by: Jason Huang | last post by:
Hi, In the C# 1.1 Windows Form, is it possible to close a MessageBox after 0.5 second without the user's clicking (or keypressing) anything on the MessageBox control? Thanks for help. Jason
1
by: =?Utf-8?B?RG91Zw==?= | last post by:
I have a really simple line of code -- myAns = MessageBox.Show(sb.ToString(), "Send Confirmation", MessageBoxButtons.YesNo; But, what I would like to happen is if the user presses <ENTERthe...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.