c#openFileDialog读取文件

  c#  打开并一行一行对取文件

openFileDialog1.ShowDialog();
            System.Diagnostics.Trace.WriteLine(openFileDialog1.FileName.ToString());
            using (StreamReader sr = new StreamReader(openFileDialog1.FileName.ToString()))
            {
                string str = "";
                int i = 0;
                str = sr.ReadLine().Trim();
                i = str.Length;
                if (i != 0)
                {
                    System.Diagnostics.Trace.WriteLine(str.ToString());
                }
                else
                {
                    System.Diagnostics.Trace.WriteLine("没有数据");
                }
            } 

你可能感兴趣的:(c#openFileDialog读取文件)