StreamWriter在写入文本文件时截断文本

Pun*_*ant 3 c# asp.net

我在字符串变量中有一个巨大的HTML内容,我想使用流编写器将该内容写入文本文件,但流编写器正在截断文本.它并不是要记录整个内容.我使用以下代码: -

using (StreamWriter sw = new StreamWriter(completeFilePath))
{
    sw.Write(Html);
}
Run Code Online (Sandbox Code Playgroud)

其中Html是字符串类型变量.请帮忙.

Ade*_*eel 6

写入后,使用Flush方法清除缓冲区.

sw.Write(Html);
sw.Flush();
Run Code Online (Sandbox Code Playgroud)