各位大侠帅哥,小女子求助如何在c# web应用程序中把服务器上的内容下载到客户端任一选定的路径下?????

WhiteExcel 2003-07-29 01:44:51
请教各位高手,如何在web应用程序中用c#调用SaveFileDialog这个控件?用c#如何把服务器上的内容下载到客户端任一选定的路径下?
...全文
40 8 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
WhiteExcel 2003-09-22
  • 打赏
  • 举报
回复
lesho()每种文件类型都要自己写入,有多少种文件类型就要写多少种的话,不是很方便,对吧!
WhiteExcel 2003-09-22
  • 打赏
  • 举报
回复
lesho()每种文件类型都要自己写入,有多少种文件类型就要写多少种的话,不是很方便,对吧!
sbzb 2003-08-05
  • 打赏
  • 举报
回复
你们两真快乐
WhiteExcel 2003-08-05
  • 打赏
  • 举报
回复
非常感谢:lesho(),猜测的吧,我猜测对了吗?
lesho 2003-08-01
  • 打赏
  • 举报
回复
你怎么知道我很帅?这个你都知道:)
WhiteExcel 2003-07-31
  • 打赏
  • 举报
回复
谢谢楼上的帅哥lesho()
pipibug 2003-07-29
  • 打赏
  • 举报
回复
收!
lesho 2003-07-29
  • 打赏
  • 举报
回复
public void OutPut(System.Web.UI.Control ctl)
{
string format="";
string strContentType="";
if(rbPDF.Checked) //get format selected
{
format=".pdf";
strContentType="application/pdf";
}
else if(rbExcel.Checked)
{
format=".xls";
strContentType="application/ms-excel";
}
else if(rbWord.Checked)
{
format=".doc";
strContentType="application/msword";
}

string strFileName=Request.QueryString["menuName"];
strFileName=strFileName.Replace("/","-");
HttpContext.Current.Response.AppendHeader("Content-Disposition","attachment;filename="+HttpUtility.UrlEncode(strFileName)+format);
HttpContext.Current.Response.Charset ="UTF-8";
//HttpContext.Current.Response.ContentEncoding=System.Text.Encoding.GetEncoding("GB2312");
HttpContext.Current.Response.ContentEncoding =System.Text.Encoding.Default;
HttpContext.Current.Response.ContentType =strContentType; //ms-excel/image/JPEG;text/HTML;image/GIF;vnd.ms-excel/msword
ctl.Page.EnableViewState =false;
System.IO.StringWriter tw = new System.IO.StringWriter() ;
System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter (tw);
ctl.RenderControl(hw);
HttpContext.Current.Response.Write(tw.ToString());
HttpContext.Current.Response.End();

}

111,097

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧