13
Reply

specify file name and path in streamwriter

Matthew Pawelke

Matthew Pawelke

May 28 2010 1:44 PM
9k

I want to create a new notepad file and specifiy file location and name i have: i'm getting an error that says empty path name is illegal
SaveFileDialog
saveFile = new SaveFileDialog();
string filePath = saveFile.FileName;
StringBuilder sb = new StringBuilder();
if (saveFile.ShowDialog() == DialogResult.OK)
{
... assign data to string
}
StreamWriter sw = new StreamWriter(filePath);
sw.WriteLine(sb);
sw.Close();

Answers (13)