我似乎找不到一种方法来通过c#编写整个HTML文件,我只能找到逐行编写它的方法,但有没有一种方法可以一次添加所有内容?对不起,我的英语不好。
这是我目前所拥有的:
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/">");
}
}发布于 2012-09-25 16:47:10
您可以使用System.IO.File.WriteAllText将字符串写入文件。
https://stackoverflow.com/questions/12579266
复制相似问题