讀取txt檔時...文字變成亂碼

txt相關

當我們在讀取txt檔時,如果遇到了亂碼

若你剛好與我一樣 使用的是StreamReader

那只要加上編碼設定即可...

如下↓

using (StreamReader sr = new StreamReader(path, System.Text.Encoding.Default))
{
    xxx
}

更多詳情以及了解請去 MSDN

We all change, when you think about it, we're all different people; all through our lives, and that's okay, that's good, you've gotta keep moving, so long as you remember all the people that you used to be. I will not forget one line of this, not one day, I swear.