我以前写的你可以参考下..string FileName = "你要下载的服务器的文件名";
string destFileName = "你要保存的路径";
if( System.IO.File.Exists(destFileName ))
{
System.IO.FileInfo fi = new System.IO.FileInfo(destFileName);
Response.Clear();
Response.ClearHeaders();
Response.Charset = "utf-8";
Response.Buffer = true;
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.AppendHeader("Content-Disposition","attachment;filename=" +Server.UrlEncode( System.IO.Path.GetFileName( FileName )));
Response.AppendHeader("Content-Length",fi.Length.ToString());
Response.ContentType="application/octet-stream";
Response.WriteFile(destFileName);
Response.Flush();
Response.Close();
Response.End();
}
解决方案 »
- 实现页面后退功能
- 如何使 treeview 复选框每次只能选中一个
- |M| 事ItemCommand中Repeater如何得到绑定时的那一行的数据
- 大虾救命啊!repeater 嵌套中(DataRowView)出错
- datagrid这个控件超级链接列的问题
- 多多幫忙!!
- 调用ocx时出现c:\inetpub\wwwroot\WebApplication3\WebForm1.aspx.cs(23): 不可访问“PDFViewer.PDFViewClass.PDFViewClass()”,因为它
- 关于不能启动asp.net调试的问题,急
- 菜鸟问题,见笑了。
- asp.net页面状态的问题,应该是比较典型的问题,微软的专家请看!
- 急求网站模版
- 个人急求职..................北京地区
string path = "D:\MYDOWNS";
if(!Directory.Exists(path))
Directory.CreateDirectory(path);
path = path + @"\";//保存路径
// Download the image
WebClient client = new WebClient();
// Download the data to a file.
client.DownloadFile(imgurl, path+@"MSxinjishu300X60.gif");
Console.WriteLine("Download URL="+imgurl);
client.Dispose();
----------------------------------------------------
真的吗?