FileStream没有获取文件当前指针位置的方法?StreamWriter.Write()写入文件后。如何获取文件当前位置指针?FileStream.Length获取的是文件总大小,在这没有用

解决方案 »

  1.   

    System.IO.FileStream fs = new System.IO.FileStream(filePath, System.IO.FileMode.Open); 
    byte[] b= new byte[fs.Length]; 
    fs.Read(b, 0, (int)fs.Length); 
    MemoryStream m= new MemoryStream(b, 0, b.Length);  MemoryStream  m=  new  MemoryStream(b,true);  
    m.Read(b,0,b.Length);  
    m.Position = 0;  
      

  2.   

    你Seek一下,看看fs. Position还==fs.Length不?
      

  3.   

    seek,是等于文件指针位置。问题是Position的值大于写入的字符串长度。如果按Position大小来读取,会出错的。问题到底在哪儿
      

  4.   

    绝对不可以Position或Length的计算结果来读取字符串,它们计算的都是字节,没有别的参照值可用时,只能用Position的计算结果读取为byte[],然后再转换成string