下载后的
源文件
客户端
requestData.FileName = dl.FileName; fileInfo = client.DownFile(requestData); System.IO.Stream so=new System.IO.FileStream("E:\\迅雷下载\\App_Code\\"+requestData.FileName,System.IO.FileMode.Create); byte[] buffer = new byte[4096]; int bytesRead = 0; bytesRead = fileInfo.FileByteStream.Read(buffer, 0, buffer.Length); int osize = (int)fileInfo.size; while (osize > 0) { System.Windows.Forms.Application.DoEvents(); so.Write(buffer, 0, bytesRead); } so.Close();
wcf
string filePath = System.IO.Path.Combine("E:\\迅雷下载", fileName.FileName); System.IO.FileInfo fileInfo = new System.IO.FileInfo(filePath); if (!fileInfo.Exists) { throw new System.IO.FileNotFoundException("File not found", fileName.FileName); } System.IO.FileStream fs = new System.IO.FileStream(filePath, System.IO.FileMode.Open, System.IO.FileAccess.Read); result.name = fileName.FileName; result.size = fileInfo.Length; result.FileByteStream = fs;
给看看这是啥情况
是用webclient吗?看到貌似又不是
不然这里应该是fileInfo = client.DownLoadFile(url);//我这里用的是url
如果这个没问题的话,那就看下载下来的文件是怎样的,如果每个都是这么小的话,那可能是加了防盗链,你就需要用httpwebrequest去模拟了
我用的wcf