asp.net从服务器上下载文件怎样去掉完整的目录?
C:\DocumentsandSettings\Administrator\桌面\Q_201109011111\小额贷款综合业务版V3.0稳定版\workfile\Web...
C:\Documents and Settings\Administrator\桌面\Q_201109011111\小额贷款综合业务版V3.0稳定版\workfile\Web\ZXEXPORT\Q_201109011111
展开
展开全部
把你下载的代码贴出来吧
更多追问追答
追问
string filename = Server.MapPath("DownLoad\\abc.rar");
FileInfo file = new FileInfo(filename);
Response.Clear();
Response.Charset = "GB2312";
Response.ContentEncoding = Encoding.Default;
Response.AddHeader("Content-Disposition", "attachment;filename=" + file.Name);
Response.AddHeader("Content-Length", file.Length.ToString());
Response.WriteFile(file.FullName);
Response.End();
追答
你用System.IO.Path.GetFileName(file.FullName)试试,
不行就截取字符串吧,不过比较麻烦
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询