C#文件访问

using System.IO;
using System.Diagnostics;
private void button3_Click(object sender, EventArgs e)
        {
            OpenFileDialog dig = new OpenFileDialog();
            DialogResult result = dig.ShowDialog();
            if (result == DialogResult.OK)
            {
                string path = dig.FileName;
                FileStream file = new FileStream(path, FileMode.Open);
                StreamReader read = new StreamReader(file, Encoding.UTF8);
                
                string []strSpite = null;
                while(true)
                {
                    string strline = read.ReadLine();
                    if (strline == null || strline.Length == 0) break;
                    strSpite = strline.Split('\t');
                    Debug.WriteLine(strSpite[0]+"\t"+strSpite[1]+"\t"+strSpite[0]);
                }
            }
        }

utf-8格式的txt文件

猜你喜欢

转载自blog.51cto.com/9233403/2235484