Reputation: 4088
I can't seem to find a way to write an entire HTML file via c#, I can only find something to write it line by line, but is there a way to add it all at once? Sorry for my bad English :(.
This is what I have at the moment:
string path = @"c:\MyTest.html";
// This text is added only once to the file.
if (!File.Exists(path))
{
// Create a file to write to.
using (StreamWriter sw = File.CreateText(path))
{
sw.WriteLine(@"<script type="text/javascript/">");
}
}
Upvotes: 0
Views: 1100
Reputation: 2590
You can write a string to a file using System.IO.File.WriteAllText
.
Upvotes: 2