转向不就暴露 mp3 地址了吗, 而且我不打算给放歌那个文件夹启动iis服务,让它和internet 分离

解决方案 »

  1.   

    "Content-disposition",attachment;参数强制文件必须保存,你可以取消它。
      

  2.   

    问题解决了,谢谢大家的力量:
    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();