Hello, I have a problem with one basic method - saving a text file. I have no idea why it doesn't work:

static void Main()
{
Console.Write("Write the statement:");

Console.Write("Write the name of the file:");

StreamWriter file = new StreamWriter("c:\\" + file_name + ".txt");

file.WriteLine(statement);
}

Thanks for any help!

4
Contributors
5
Replies
6
Views
6 Years
Discussion Span
Last Post by sknake

file.close();

doesnt work.

if you are using windows vista or seven it could be privilege issue try to save another path or run as administrator

In either case, I would put the file operations in a try/catch block.
the exception.Message will tell you the error.

It is probably that youur account does not have permission to write in the root of C.

Edited by thines01: n/a

Try this:

void button1_Click(object sender, EventArgs e)
{
}