My application allows the user to select a particular file to import from a ToolStripDropDownButton. The code then displays an OpenFileDialog for them to browse to the file to import.
As the file actually chosen may be different from the selected ToolStripDropDownButton item, I want to prevent an incorrect file from being copied. I wrote a method which compares the two selections and displays a RetryCancel DialogResult in a MessageBox.
If the user clicks "Retry", I want to return to the calling code's OpenFileDialog for the user to make another file selection.
If the user clicks "Cancel", I do Not want to exit the application, just allow the user to continue using the application.
How do I return to the calling code's OpenFileDialog based on the "Retry" button and how can I handle the "Cancel" button?
I have attached the simple method example. Thank you in advance.
Loading
VulpesPosted Jan 2, 2013, 7:14 AM
Richard ArnoldPosted Jan 5, 2013, 7:42 PM
Your solution was exactly what I needed. I actually had 4-different files to evaluate.
Using your suggestion with a slight modification of a Ternary statement, I am able to confirm whether the users initial file-import choice matches their actual file selection and if not, to display a warning along with the FileDialog again.
Thank you very much for your consideration in this matter. It is appreciated.