Download to specified path:
System.Net.WebClient client = new System.Net.WebClient();
client.DownloadFile(strURL, strLocalPath);
Download without specified path:
//strFile: your physical file path in server
FileInfo fInfo = new FileInfo(strFile);
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=" + fInfo.Name);
Response.AddHeader("Content-Length", fInfo.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.WriteFile(fInfo.FullName);
System.Net.WebClient client = new System.Net.WebClient();
client.DownloadFile(strURL, strLocalPath);
Download without specified path:
//strFile: your physical file path in server
FileInfo fInfo = new FileInfo(strFile);
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=" + fInfo.Name);
Response.AddHeader("Content-Length", fInfo.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.WriteFile(fInfo.FullName);
Comments
Post a Comment