Hello guys help please i'm trying to write to a disk and append it whenever i open the program i can add to it instead of witting a new one

StreamWriter Write;
Write = File.CreateText("c:\\TestFile.txt", FileMode.Append);
Write.WriteAllText(txtOutput.Text);
Write.Close();
MessageBox.Show ("File Created SucacessFully");
getting this error:-
No overload for method 'CreateText' takes '2' arguments
'System.IO.StreamWriter' does not contain a definition for 'WriteAllText' and no extension method 'WriteAllText' accepting a first argument of type 'System.IO.StreamWriter' could be found (are you missing a using directive or an assembly reference?) (CS1061)


and i have using System.IO
in the directive

Recommended Answers

All 3 Replies

System.IO.File.AppendAllText(filePath, content);

In your case

System.IO.File.AppendAllText(@"c:\TestFile.txt", txtOutput.Text);

Thanks that fix the problem i have been having how do i rate you up?

You're welcome, Add to Ramy Mahrous's Reputation, then I approve and put your comment :)
Please mark this thread as solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.