文本数据如下
4142女性其中‘’为隐藏字符,代码为:0x1b
请问我该怎么攫取,谢谢!

解决方案 »

  1.   

    string[] arr=File.ReadAllLine("")
    File.ReadAllText
    Split分割
    或StreamReader
      

  2.   

                string fileName = "d:\\1.txt";            byte[] byteContent = System.IO.File.ReadAllBytes(fileName);将文本中的数据读到byte的数组中,然后对数组进行操作,byteContent[1]和byteContent[3]就是你要的内容.
      

  3.   

                    string path = @"D:\\test.txt";        //路径
                    FileStream file = new FileStream(path, FileMode.Open);//打开
                    byte[] bt = new byte[file.Length];         //建立
                    file.Read(bt, 0, bt.Length);               //读取
                    string a = Encoding.UTF8.GetString(bt);    //编码转换                a就是文本的内容
                      这时文本打开了还没关闭
                      要再加个file.Close();代码是我自己写的,可能注释写的不是很好
      

  4.   

    byte[] byteContent = System.IO.File.ReadAllBytes(fileName);
      

  5.   

    先 FileStream file = new FileStream(path, FileMode.Open)
    然后 用 StreamReader sr=new StreamReader(file);
      while(sr.EndOfStream==false){
          sr.read();
    或者 sr.readline();
    }
      

  6.   

    StreamReader sr=new StreamReader(file); 
      while(sr.Peek() >= 0){ 
     string line=sr.readline();
     string[] strs= line.Split(new char[]{''});
    }
    上面strs数组就是以''分割开的字符串