How to read text files with ANSI encoding and non-English letters?

前端 未结 4 1005
走了就别回头了
走了就别回头了 2020-12-02 20:21

I have a file that contains non-English chars and was saved in ANSI encoding using a non-English codepage. How can I read this file in C# and see the file content correctly?

4条回答
  •  猫巷女王i
    2020-12-02 20:44

    using (StreamWriter writer = new StreamWriter(File.Open(@"E:\Sample.txt", FileMode.Append), Encoding.GetEncoding(1250)))  ////File.Create(path)
            {
                writer.Write("Sample Text");
            }
    

提交回复
热议问题