----赖格英-----

记忆不好了,记录工作中的点点滴滴....

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
OpenFileDialog OFD = new OpenFileDialog();
            OFD.Title = "打开第一个文本文件";
            OFD.FileName = "*.txt";
            OFD.InitialDirectory = WorkSpacePath;
            if (OFD.ShowDialog() == DialogResult.OK)
            {
                FileInfo fi = new FileInfo(OFD.FileName);
                StreamReader sr = fi.OpenText();
                while (sr.Peek() > 0)
                {
                    listBox1.Items.Add(sr.ReadLine());
                }
                sr.Close();
                textBox1.Text = OFD.FileName;
                this.statusStrip1.Items[1].Text = listBox1.Items.Count.ToString();
            }

写一个文本文件:

string Path = Application.StartupPath;
            FileStream fs = new FileStream(Path + "\\path.dll", FileMode.Create, FileAccess.Write);
            StreamWriter sw = new StreamWriter(fs);
            sw.WriteLine(path08);
            sw.WriteLine(path07);
            sw.WriteLine(path06);
            sw.WriteLine(WorkSpacePath);
            sw.WriteLine(EFDCPath);
            sw.WriteLine(path09);
            sw.Close();
            fs.Close();

 

 

posted on 2014-01-12 20:37  向北方  阅读(12385)  评论(0编辑  收藏  举报