jamie

jamie

  • NA
  • 26
  • 0

help with this code

Jan 11 2008 11:11 PM

i am a newbie to programming. I have been working to make a Readme.txt generator. it is working, but i am having trouble finishing it. My problem is that i cannot get it to not overwrite the existing readme. I have it so that it will generate the readme file and save it to the desktop but when the file is already there, i tell the user that a file already exists, and ask if they want to overwrite. if you choose no, it still overwrites.

 

if ((text1.Equals("")) || (text4.Equals("")) || (text6.Equals("")) || (GameSet == false) || (MapSize == false)) //this line tells the system to not generate the readme if these errors occur

return;

string strFile = "ReadMe.txt";

if (File.Exists(strFile))

{

DialogResult dr = MessageBox.Show("A ReadMe file already exists here. do you want to overwrite it?", "Error", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);

if (dr == DialogResult.No)

{

MessageBox.Show("the file was not overwritten");

return;

}

else

MessageBox.Show("The ReadMe has been successfully Generated", "Done!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

}

}


Answers (6)