C# 将代码保存成文件

/// <summary>
///  将代码保存成文件
/// </summary>
/// <param name="path"></param>
private void getOnFile(string path)
{
    string path_old = "C:/Documents and Settings/Administrator/桌面/dlq.aspx";
    string codeall = this.getallcode(path_old);//这里是我读取的代码

    StreamWriter sw = new StreamWriter(@path);
    sw.Write(codeall);
    sw.Flush();
    sw.Close();
}

//注意:将代码保存成文件时,像换行这样的代码,必须使用严格的转义字符,例如,要实现空格,就必须

//每读完一行+"\r\n";

原文地址:https://www.cnblogs.com/binlunia/p/11267805.html