It's difficult to answer this question without seeing the calling code but, if I were you, I'd just let this method check whether the user file selection is acceptable and let the calling code deal with the repercussions of it not being.
You could therefore just reduce the method to this, returning a bool:
private bool ConfirmCorrectFileSelection(string myFile, string pubType) // Confirm user file selection matches the ToolStripDropDown choice
{
if (myFile.Contains("Some selected text") & pubType == "Similar text") return true;
return false;
}
I'd then place the code which calls the OpenFileDialog in a while(true) loop and call the above method from within the loop. You'd then end up with something like this:
while(true)
{
// code to call OpenFileDialog
if (ConfirmCorrectFileSelection(myFile, oubType))
{
break; // no need to call OpenFileDialog again
}
else
{
string message = "You chose to import a file but selected a different file. Please correct your selection.";
string caption = "Your File Selection is INCORRECT!";
MessageBoxButtons buttons = MessageBoxButtons.RetryCancel;
DialogResult result;
//Display the MessageBox.
result = MessageBox.Show( message, caption, buttons );
if (result == DialogResult.Cancel)
{
// continue operation
e.Cancel = true; // if needed, see below
break;
}
// otherwise Retry must have been pressed and loop will continue and OpenFileDialog will be called again
}
}