I need to show some message to user when a file exist, that display the message "the files exist... do you want to overwrite it??"
if (File.Exists(binaryFilePath))
{
Program.DisplayMessage("The file: " + binaryFileName + " exist. You want to overwrite it? Y/N");
string overwrite = Console.ReadLine();
while (overwrite != null)
{
if (overwrite.ToUpper() == "Y")
{
WriteBinaryFile(frameCodes, binaryFilePath);
} if (overwrite.ToUpper() == "N")
{
throw new IOException();
overwrite = null;
} if (overwrite.ToUpper() != "Y" && overwrite.ToUpper() != "N")
{
Program.DisplayMessage("!!Please Select a Valid Option!!");
overwrite = Console.ReadLine();
}
}
}
if the user write "Y" the process start and done normal... the problem is how can stops?? I try with this while, but not work...
How can I do this?