C#图片遇到的超级好玩的问题,会的进来,分数全拿
http://www.to369.cn/UploadPhoto/Book/595/200703142223211.gif
这张图片.用一下两种代码都下不下来:
string url = "http://www.to369.cn/UploadPhoto/Book/595/200703142223211.gif ";
string newName = "1.gif ";
//方法一
WebClient webClient = new WebClient();
webClient.DownloadFile(url, ( "C:\\ " + newName));
//方法二
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
FileStream fs = new FileStream( "C:\\2 " + newName, FileMode.CreateNew);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream stream = response.GetResponseStream();
const int bufferLength = 2048;
byte[] contents = new byte[bufferLength];
int count = 0;
int readBytes = 0;
do
{
readBytes = stream.Read(contents, 0, bufferLength);
if(readBytes > 0)
fs.Write(contents, 0, readBytes);
count += readBytes;
}
while (readBytes != 0);
fs.Close();
stream.Close();
但是用迅雷或右键另存为,都可以下,怎么解决呢?
------解决方案--------------------