-1

Writing a winforms application. I have created a yes/no message box, displayed to the user when they are trying to delete a file but I would like to add the recycle bin image to the message. How do you get access, for use with things like message boxes systems icons/images?

MessageBox.Show("Please confirm that you would like to delete the folder named:" + fldnme, 
                        "Confirm Folder Delete", 
                        MessageBoxButtons.YesNo, 
                        MessageBoxIcon.Exclamation);

Obviously I would be replacing the messageboxicon with?

Thanks

flavour404
  • 6,184
  • 30
  • 105
  • 136

1 Answers1

3

Short answer: you cannot.

The Win32 MessageBox window only lets you choose one of four icons (the other members of MessageBoxIcon are synonyms) that corresponds to the purpose of a messagebox:

  • Ask the user a confirmation question (a Yes/No messagebox with a Question-mark icon)
  • To warn the user (usually a single button with a warning triangle icon)
  • To inform the user of some information (usually a single button with an "i" icon)
  • To inform the user of a serious error (usually a single button with a red stop icon)

In your use-case, to ask the user to confirm the deletion of a file, you should use either the Question-mark icon or the Warning triangle icon.

I'm going to assume that you call File.Delete if the user selects Yes rather than moving the file to the Recycle Bin. If this is the case then you really shouldn't use the Recycle Bin icon (even if you could) because you aren't moving it to the bin, you're deleting it straight away.

Dai
  • 141,631
  • 28
  • 261
  • 374
  • Ok, let's assume that I am writing an application that does move the file to the recycle bin, how would you it then? Your answer is very complete thanks. – flavour404 Apr 17 '13 at 22:08
  • You would have to reimplement your own MessageBox: http://stackoverflow.com/questions/6560493/messagebox-show-custom-icon – Dai Apr 17 '13 at 22:40