我想从asp.net c#中的共享文件夹下载文件 [英] I want to download file from shared folder in asp.net c#

查看:523
本文介绍了我想从asp.net c#中的共享文件夹下载文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我很麻烦..我想从网站下载文件,但问题是IIS和共享文件夹在不同的服务器上。所以我无法完全下载该文件。该文件被下载,但它已损坏或只有实际数据超过10分钟左右的秒数



我的代码是

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

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();

推荐答案

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\ _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 = 应用/八位字节流;
byte [] data = wc.DownloadData(filePath);
response.BinaryWrite(data);
EndResponse();
\\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();


访问这里...





http://www.aspdotnet-suresh .com / 2012/02 / saveupload-files-in-folder-and-download.html [ ^ ]
visit here...


http://www.aspdotnet-suresh.com/2012/02/saveupload-files-in-folder-and-download.html[^]


这篇关于我想从asp.net c#中的共享文件夹下载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆