List<String> list = new List<string>();
StreamReader reader = new StreamReader(path);//path为文本路径
while(true)
                {
                    string value = reader.ReadLine();
                    if(String.IsNullOrEmpty(value))
                        break;
                    list.Add(value);
                }
                reader.Dispose();
                reader.Close();
读取完毕后自己再根据需要处理下字符串

解决方案 »

  1.   

     string connectstr = "server=localhost;Database=test;User ID=root;Password=root";
                MySqlConnection conn = new MySqlConnection(connectstr);
                conn.Open();
                string path = @"C:\Users\Administrator\Desktop\test.txt";
                List<String[]> list = new List<string[]>();
                StreamReader reader = new StreamReader(path);//path为文本路径
                string[] va = null;
                while (true)
                {
                    string value = reader.ReadLine();
                    if(value != null)
                    {
                        va = Regex.Split(value, "^|", RegexOptions.IgnoreCase);
                    }
                    if (String.IsNullOrEmpty(value))
                        break;
                    list.Add(va);
                }
                reader.Dispose();
                reader.Close();split没起作用为什么呢
      

  2.   

     va = value.Split(new char[2] { '^', '|' });没法去空格