Click here to Skip to main content
15,903,175 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am trouble.. I want to download a file from a website, but the problem is that the IIS and shared folder are in different servers. So i am not able to fully download the file. The file gets downloaded but its either corrupt or only seconds where the actual data is more than 10 mins or so

My code is
C#
string filePath = "\\\\ipaddress\\c$\\Web\\Application\\Temp\\SleepAway.mp3";
var uri = new Uri(filePath);
string filename = Path.GetFullPath(uri.LocalPath);
HttpResponse response = HttpContext.Current.Response;
response.Clear();
response.ClearContent();
response.ClearHeaders();
response.Buffer = false;

WebClient wc = new WebClient();
response.AddHeader("Content-Disposition", string.Format("attachment;filename={0}", Path.GetFileName(filePath)));
response.ContentType = "application/octet-stream";
byte[] data = wc.DownloadData(filePath);
response.BinaryWrite(data);
EndResponse();
Posted
Updated 2-Oct-13 2:37am
v2

1 solution

 
Share this answer
 
Comments
Arjun Menon U.K 2-Oct-13 8:45am    
So u are telling me to download the file from Server To A Folder In Another Server And then download from that folder?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900