write Request.InputStream into a txt file.

Request.InputStream return the type of System.IO.Stream, so we can write the data into a file.
Coding as follow:

    string StrFileName="c:\\1.txt";
   System.IO.FileStream fs = new System.IO.FileStream(StrFileName,System.IO.FileMode.Create);
   System.IO.Stream ns=Request.InputStream;
   byte[] nbytes = new byte[512];
   int nReadSize=0;
   nReadSize=ns.Read(nbytes,0,512);
   while( nReadSize >0)
   {
    fs.Write(nbytes,0,nReadSize);
    nReadSize=ns.Read(nbytes,0,512);
   }
   fs.Close();
   ns.Close();
posted @ 2004-09-27 11:02  23热爱,自学业余码农。  阅读(1091)  评论(0编辑  收藏  举报