Reputation: 181
if (string.IsNullOrEmpty(indata))
{
StreamWriter sw = new StreamWriter(@"c:\arjun.txt", true);
sw.WriteLine("0");
sw.Close();
}
This is my code. How can I overwrite a result in arjun.txt
file I need single result.
Upvotes: 1
Views: 989
Reputation: 1500525
The true
part means "append" - either just get rid of it entirely, in which case you'll use the StreamWriter
constructor overload which overwrites by defalut, or change true
to false
.
Or preferably, just use:
File.WriteAllLines(@"c:\argun.txt", new[] {"0"});
When you can specify all the data in one go, the convenience methods in File
are really helpful.
Upvotes: 4