我看了大家关于下载的代码,回去试了一下,不用工具下载的话,可以成功.但用迅雷的话下载的文件是本网页.以下是代码,望指教!!!
string name = ("Doc2\\")+"Employees.xml";
FileInfo aFile = new FileInfo(Server.MapPath(name));
string na = Path.GetFileName(name);
string hz = "." + name.Substring(name.LastIndexOf(".") + 1);//获取文件的后缀
//清除缓冲区流中的所有内容输出
Response.Clear();
Response.ClearHeaders();
Response.BufferOutput = false;
Response.ContentType = "application/octet-stream";
Response.AppendHeader("Content- disposition", "attachment;filename=" + HttpUtility.UrlEncode("baocun" + hz, Encoding.UTF8));
Response.AppendHeader("Content-Length", aFile.Length.ToString());
Response.WriteFile(aFile.FullName);
Response.End();
string name = ("Doc2\\")+"Employees.xml";
FileInfo aFile = new FileInfo(Server.MapPath(name));
string na = Path.GetFileName(name);
string hz = "." + name.Substring(name.LastIndexOf(".") + 1);//获取文件的后缀
//清除缓冲区流中的所有内容输出
Response.Clear();
Response.ClearHeaders();
Response.BufferOutput = false;
Response.ContentType = "application/octet-stream";
Response.AppendHeader("Content- disposition", "attachment;filename=" + HttpUtility.UrlEncode("baocun" + hz, Encoding.UTF8));
Response.AppendHeader("Content-Length", aFile.Length.ToString());
Response.WriteFile(aFile.FullName);
Response.End();
Set fl=fso.getfile(url)
flsize=fl.size
flName=fl.name
Set fl=Nothing
Set fso=Nothing
Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = 1
objStream.LoadFromFile url
Select Case lcase(Right(flName, 4))
Case ".asf"
ContentType = "video/x-ms-asf"
Case ".avi"
ContentType = "video/avi"
Case ".doc"
ContentType = "application/msword"
Case ".zip"
ContentType = "application/zip"
Case ".xls"
ContentType = "application/vnd.ms-excel"
Case ".gif"
ContentType = "image/gif"
Case ".jpg", "jpeg"
ContentType = "image/jpeg"
Case ".wav"
ContentType = "audio/wav"
Case ".mp3"
ContentType = "audio/mpeg3"
Case ".mpg", "mpeg"
ContentType = "video/mpeg"
Case ".rtf"
ContentType = "application/rtf"
Case ".htm", "html"
ContentType = "text/html"
Case ".txt"
ContentType = "text/plain"
Case Else
ContentType = "application/octet-stream"
End Select
Response.AddHeader "Content-Disposition", "attachment; filename=" & flName
Response.AddHeader "Content-Length", flsize
Response.Charset = "UTF-8"
Response.ContentType = ContentType
Response.BinaryWrite objStream.Read
Response.Flush
response.Clear()
objStream.Close
Set objStream = Nothing
试一下这个