相关疑难解决方法(0)

如何从C#中读取中文文本?

如何使用C#读取中文文本文件,我当前的代码无法显示正确的字符:

try
{    
    using (StreamReader sr = new StreamReader(path,System.Text.Encoding.UTF8))
    {
        // This is an arbitrary size for this example.
        string c = null;

        while (sr.Peek() >= 0)
        {
            c = null;
            c = sr.ReadLine();
            Console.WriteLine(c);
        }
    }
}
catch (Exception e)
{
    Console.WriteLine("The process failed: {0}", e.ToString());
}
Run Code Online (Sandbox Code Playgroud)

c# text-files

4
推荐指数
2
解决办法
8869
查看次数

标签 统计

c# ×1

text-files ×1