跳到主要內容

發表文章

目前顯示的是 8月, 2013的文章

C# OpenFileDialog 讀寫文字檔(指定編碼)

讀取 private string getReadText() { OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.InitialDirectory = "."; openFileDialog1.Filter = "文字檔 (*.txt)|*.txt"; if (openFileDialog1.ShowDialog() != DialogResult.OK) return ""; StreamReader sr = new StreamReader(openFileDialog1.OpenFile(), System.Text.Encoding.Default); return sr.ReadToEnd(); } 寫入 private void saveFile(string filaPath, string Content) { FileStream fs2 = File.Open(filaPath, FileMode.Create, FileAccess.Write); StreamWriter sw = new StreamWriter(fs2,,System.Text.UnicodeEncoding.UTF8); sw.Write(Content); sw.Close(); }

C# 國考日期板

C# 偏好設定