FileStream fs=new FileStream(path,...);
byte[] bint=new byte[10];
fs.Read(b,0,b.Length);
byte[] bchar=new byte[10];
fs.Read(bchar,10,bchar.Length);
byte[] bm=new byte[10];
fs.Read(bm,20,bm.Length);

解决方案 »

  1.   

    Stream只能读Txt文档.如果要读Doc,用WordApplication.
      

  2.   

    howbigsea(大海) 
    怎样转换类型,bint,bchar,bm返回的都是asc2码啊!!!
      

  3.   

    howbigsea(大海) 
    怎样转换类型,bint,bchar,bm返回的都是asc2码啊!!!
      

  4.   

    .txt行了,
    可读.doc文件是一堆乱码啊!!!!!!!!!!!
      

  5.   

    strawwan(稻草人) 
    Stream只能读Txt文档.如果要读Doc,用WordApplication.能具体点吗???要能给出读出来后再写到一个文档里的代码最好了!!!!!!!!!!!!!
      

  6.   

    strawwan(稻草人) 
    Stream只能读Txt文档.如果要读Doc,用WordApplication.怎样读Doc文件,能具体点吗???要能给出读出来后再写到一个文档里的代码最好了!!!!!!!!!!!!!
      

  7.   

    先添加Microsoft Word Object Library.
    using System.IO;
    using System.Text;object fileName = "e:\\1.doc";
    object txtName = "e:\\1.txt";
    object readOnly = false;
    object isVisiable = true;
    object missing = System.Reflection.Missing.Value;Word.ApplicationClass wordApp = new ApplicationClass();
    Word.Document wordDoc = wordApp.Documents.Open(ref fileName,ref missing,ref readOnly,ref missing,ref missing,ref missing,ref missing,ref missing,ref missing,ref missing,ref missing,ref isVisiable);string wordContent = wordDoc.Content.Text;    //Word文档的正文内容.wordDoc.Close(ref missing,ref missing,ref missing);FileStream fs = new FileStream(txtName.ToString(),FileMode.OpenOrCreate);StreamWriter sw = new StreamWriter(fs,Encoding.Default);sw.Write(wordContent);
    sw.Flush();
    sw.Close();
    fs.Close();这段代码是读1.doc再另存为1.txt文档.不同的Word Object Library 版本可能代码也有差异.自己可以试一下.