Forcing StreamWriter to change Encoding

后端 未结 5 1223
没有蜡笔的小新
没有蜡笔的小新 2020-12-14 06:58

I am trying to save a file using DialogResult and StringBuilder. After making the text, I am calling the following code to save the file:



        
5条回答
  •  遥遥无期
    2020-12-14 07:37

    The easiest way is to use the right constructor.

    StreamWriter(String, Boolean, Encoding)
    

    Initializes a new instance of the StreamWriter class for the specified file by using the specified encoding and default buffer size. If the file exists, it can be either overwritten or appended to. If the file does not exist, this constructor creates a new file.

    C#

    public StreamWriter (string path, bool append, System.Text.Encoding encoding);
    

提交回复
热议问题