This code:
--code start--
private void WriteFile()
{
StreamWriter sw =
new StreamWriter(Fi le.Create("test .txt"));
sw.Write("test" );
sw.Close();
}
private void button1_Click(. ..) {
OpenFileDialog myFileDialog = new OpenFileDialog( )
if (myFileDialog.S howDialog() == DialogResult.OK )
{
WriteFile();
}
}
private void button2_Click(. ..)
{
WriteFile();
}
--code end--
WriteFile() dont create the file "test.txt" IF the file
dialog have been opened and the dialogresult is OK.
WriteFile() do create the file "test.txt" IF the file
dialog never been opened or if the dialogresult was Cancel.
Why do I get this strange error?
--code start--
private void WriteFile()
{
StreamWriter sw =
new StreamWriter(Fi le.Create("test .txt"));
sw.Write("test" );
sw.Close();
}
private void button1_Click(. ..) {
OpenFileDialog myFileDialog = new OpenFileDialog( )
if (myFileDialog.S howDialog() == DialogResult.OK )
{
WriteFile();
}
}
private void button2_Click(. ..)
{
WriteFile();
}
--code end--
WriteFile() dont create the file "test.txt" IF the file
dialog have been opened and the dialogresult is OK.
WriteFile() do create the file "test.txt" IF the file
dialog never been opened or if the dialogresult was Cancel.
Why do I get this strange error?