本帖最后由 prestashop 于 2011-06-25 10:25:29 编辑

解决方案 »

  1.   

    看了你的代码,感觉貌似在while循环中缺少点什么:你的while循环感觉只能读取一行,在this.listBox1.Items.Add(str);语句后加上一条语句
    str = sr.ReadLine();
    试试吧!
      

  2.   

    System.IO.File.ReadAllText(path, Encoding.GetEncoding("gb2312"));
      

  3.   

    string fName = openFileDialog.FileName;                  string path = fName;
                      StreamReader sr = new StreamReader(path, Encoding.GetEncoding("GB2312"));//读取文件
                      string str = sr.ReadToEnd();
    string[] strs = str.Split(System.Environment.NewLine); //或者根据其他条件分隔,                  foreach(string strTemp in strs)//判断行
                      {
                          if (strTemp.IsNullOrEmpty() ||this.listBox1.Items.Contains(strTemp)) continue;
                          this.listBox1.Items.Add(strTemp);
                      }