0

我似乎找不到通过 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/">");
    }
}
4

1 回答 1

2

您可以使用 将字符串写入文件System.IO.File.WriteAllText

于 2012-09-25T08:47:09.597 回答