问题解决了,谢谢大家的力量: FileInfo file = new System.IO.FileInfo("E:\\煤炭网程序\\Songs\\apengyouzaijia.rm"); // clear the current output content from the buffer Response.Clear(); // add the header that specifies Response.AddHeader("Content-Disposition", "filename=" + file.Name); // add the header that specifies the file size, so that the browser // can show the download progress Response.AddHeader("Content-Length", file.Length.ToString()); // specify that the response is a stream that cannot be read by the // client and must be downloaded
string fileName = file.Name.ToLower(); int lastIndex = fileName.LastIndexOf("."); fileName = fileName.Substring(lastIndex); // 根据文件后缀指定文件的Mime类型 switch (fileName) { case ".rm": Response.ContentType = "application/vnd.rn-realmedia"; break; case ".mp3": Response.ContentType = "audio/mpeg3"; break; case ".asf": Response.ContentType = "video/x-ms-asf"; break; case ".avi": Response.ContentType = "video/avi"; break; case ".wav": Response.ContentType = "audio/wav"; break; case ".mpg": Response.ContentType = "video/mpeg"; break; case "mpeg": Response.ContentType = "video/mpeg"; break; default: Response.ContentType = "application/octet-stream"; break; } // send the file stream to the client Response.WriteFile(file.FullName); // stop the execution of this page Response.End();
FileInfo file = new System.IO.FileInfo("E:\\煤炭网程序\\Songs\\apengyouzaijia.rm"); // clear the current output content from the buffer
Response.Clear();
// add the header that specifies
Response.AddHeader("Content-Disposition", "filename=" + file.Name);
// add the header that specifies the file size, so that the browser
// can show the download progress
Response.AddHeader("Content-Length", file.Length.ToString());
// specify that the response is a stream that cannot be read by the
// client and must be downloaded
string fileName = file.Name.ToLower();
int lastIndex = fileName.LastIndexOf(".");
fileName = fileName.Substring(lastIndex); // 根据文件后缀指定文件的Mime类型
switch (fileName)
{
case ".rm":
Response.ContentType = "application/vnd.rn-realmedia";
break;
case ".mp3":
Response.ContentType = "audio/mpeg3";
break;
case ".asf":
Response.ContentType = "video/x-ms-asf";
break;
case ".avi":
Response.ContentType = "video/avi";
break;
case ".wav":
Response.ContentType = "audio/wav";
break;
case ".mpg":
Response.ContentType = "video/mpeg";
break;
case "mpeg":
Response.ContentType = "video/mpeg";
break;
default:
Response.ContentType = "application/octet-stream";
break;
} // send the file stream to the client
Response.WriteFile(file.FullName);
// stop the execution of this page
Response.End();