在线等关于net文件下载无需activx插件的方法 大虾们好 我有个疑问很着急,因为苹果机无法兼容activx插件,所以我的文件下载没用,在线等大家帮我个解决方法,我的下载方法是用的文字流的方式,qq47874687 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 文件下载 需要插件吗?比如你在IIS目录下放一个TXT文件,下载就是 http://ip/目录/文件名 就能下载了 按道理说是这样,但是我上传的时候也是以文件流的形式上传的,我用的是activx插件去下载的, 你只需要在服务端生成文件即可或者Asp.net 可以在页面中直接输出文件流 public void DownloadAttachment(Page p, int NewsID, string AttID) ////字符流方式下载文件 { try { NewsAttachment newsAttachment = this.GetNewsAttachment(AttID); string text = ConfigurationSettings.AppSettings["DataDir"]; object obj2 = text; FileStream stream = File.OpenRead(string.Concat(new object[] { obj2, @"news\", NewsID, @"\" }) + newsAttachment.AttID); byte[] buffer = new byte[stream.Length]; p.Response.ContentType = "application/x-msdownload"; p.Response.AddHeader("Content-Disposition", "attachment; filename=\"" + FileService.EncodeFileNameForDownload(newsAttachment.AttFileName) + "\""); stream.Read(buffer, 0, (int) stream.Length); p.Response.BinaryWrite(buffer); stream.Close(); } catch (Exception exception) { LogService.Write("NewsMgr:DownloadAttachment()"); LogService.Write(exception.ToString()); } }这个是我的,调用的时候是这样写的 function DownloadAtt(AttID, NewsID) { UploadTool.DownloadFrom('http://<%=Request.ServerVariables["SERVER_NAME"]%>/news/download.aspx?attid=' + AttID + '&nid=' + NewsID); }uploadtool调用了activx插件 你问了半天都没有讲为什么必须要用 activx插件完全不需要的事情,过去用了,只能说用错了 你直接在IE里打开 http://<%=Request.ServerVariables["SERVER_NAME"]%>/news/download.aspx?attid=' + AttID + '&nid=' + NewsID看看 C#可以开发出像通达信,大智慧这样的炒股软件吗? 怎样给 Response.Redirct("index.aspx")指定目标框架?? 请教: .net平台和VC6的一个问题? dataGridView的问题 C#使用指针出错!! 字符串转化成十进制ascii的问题 如何获得关闭ie窗体的信息?新手,请帮帮忙. 高分:C# windows Application 如何使用Excel 的Com组件打开、修改和保存数据? 帮忙把这段JAVA程序翻译成C#版本的吧~~~~~~~~ 谁知道 腾讯新浪网易 这些公司验证码的生成程序 WEBSERVICE问题 c#如何获取URL中#号后面的内容
比如你在IIS目录下放一个TXT文件,下载就是 http://ip/目录/文件名 就能下载了
或者
Asp.net 可以在页面中直接输出文件流
try
{
NewsAttachment newsAttachment = this.GetNewsAttachment(AttID);
string text = ConfigurationSettings.AppSettings["DataDir"];
object obj2 = text;
FileStream stream = File.OpenRead(string.Concat(new object[] { obj2, @"news\", NewsID, @"\" }) + newsAttachment.AttID);
byte[] buffer = new byte[stream.Length];
p.Response.ContentType = "application/x-msdownload";
p.Response.AddHeader("Content-Disposition", "attachment; filename=\"" + FileService.EncodeFileNameForDownload(newsAttachment.AttFileName) + "\"");
stream.Read(buffer, 0, (int) stream.Length);
p.Response.BinaryWrite(buffer);
stream.Close();
}
catch (Exception exception)
{
LogService.Write("NewsMgr:DownloadAttachment()");
LogService.Write(exception.ToString());
}
}这个是我的,调用的时候是这样写的
function DownloadAtt(AttID, NewsID)
{
UploadTool.DownloadFrom('http://<%=Request.ServerVariables["SERVER_NAME"]%>/news/download.aspx?attid=' + AttID + '&nid=' + NewsID);
}uploadtool调用了activx插件
看看