13
Answers

specify file name and path in streamwriter

Matthew Pawelke

Matthew Pawelke

14y
9k
1

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)