.net 读取文件

/// <summary>
        /// 读取文本文件
        /// </summary>
        /// <param name="txtfileName">文件路径</param>
        private void FromTxtTodata(string txtfileName)
        {
            string txt = "";
            using (StreamReader reader = new StreamReader(txtfileName,Encoding.Default ))
            {
                //循环读取所有行
                //while (!reader.EndOfStream)
                //{
                   // txt += reader.ReadLine() + System.Environment.NewLine;
                //}
                txt += reader.ReadToEnd();
            }
            MessageBox.Show("导入完成!");
        }

 

posted @ 2014-11-24 14:18  小小戒  阅读(762)  评论(0编辑  收藏  举报