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
时间: 2024-10-25 19:26:55