文件流生成文件

1.
HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(url); WebResponse myResp = myReq.GetResponse(); byte[] b = null; using( Stream stream = myResp.GetResponseStream() ) using( MemoryStream ms = new MemoryStream() ) { int count = 0; do { byte[] buf = new byte[1024]; count = stream.Read(buf, 0, 1024); ms.Write(buf, 0, count); } while(stream.CanRead && count > 0); b = ms.ToArray(); }
2.

using (FileStream fs = new FileStream(filePath, FileMode.Create))
{
fs.Write(b, 0, b.Length);
}

 

http://stackoverflow.com/questions/3434007/error-this-stream-does-not-support-seek-operations-in-c-sharp

 
posted @ 2017-01-17 17:35  越界  阅读(340)  评论(0编辑  收藏  举报