有例子或者源代码最好啦。

解决方案 »

  1.   

    txt 可直接用浏览器打开
    pdf 只要客户端装Acrobat就能用浏览器打开
    rm 有real服务器
    mpg mp3 有midea player 服务器
      

  2.   

    前三种类型可以直接浏览观看,用户有相关软件就行。后面几种如果楼主真想实现在线播放的话建议安装Real的Helix Server。
      

  3.   

    如果楼主非要自己开发这个技术,那可是有点和自己过不去了。很难超过real或者Windows Media Server的水平了。
      

  4.   

    你用System.IO或者数据库读取文件的信息来确定浏览方式就是了
      

  5.   

    假如是pdf ,需要客户端装Acrobat,但是我如何做到文件和阅读工具的匹配?总不能是用户点击之后出现一个下载对话框,然后不保存,选择“直接打开”,WINDOWS发现没有装Acrobat,然后弹一个框要求选一个适合我知道很难,我看网络图书馆阅读一般要求安装特定的阅读器,比如超星,方正的XX等,他们都是把文本做成了自己的格式,再让客户端使用特定的阅读器打开。我肯定做不出来阅读器,而且文件类型繁多。有没有做成XML流来处理的可能?
      

  6.   

    呵呵,把文件用System.IO读出文件,然后根据文件类型作播放脚本即可。
      

  7.   

    foreach(FileInfo f in mainDir.GetFiles())
    {    
     n=f.Extension.ToLower();
     editname= m_CurrentDir+f.Name;
     sURL=_url+m_CurrentDir+f.Name;
     DownPath="<a href =\"./FileDownload.aspx?sPath="+editname+"\" target=\"_blank\">"+f.Name+"</a>";
     FileKey ="";//"<a href =\"./FileKey.aspx?sPath="+editname+"\"><img src=\"images/filekey.gif\"></a>";
    sb.Append("<tr><td><input type=\"CheckBox\" name=\"selectfiles\" value=\""+f.Name+"\"></td>");
    switch(n)       
    {         
    case ".htm":    
    sb.Append("<td><img src=\"images/html.gif\">&nbsp;" + DownPath +  "&nbsp;\n<a href="+sURL+" target=\"_blank\"><img src=\"images/ie.gif\" width=16 height=16 border=0 alt=\"浏览\"></a>&nbsp;\n<a href=\"editfile.aspx?name="+editname+"&type=file\"><img src=\"images/edit.gif\" width=16 height=16 border=0 alt=\"编辑\"></a>&nbsp;\n&nbsp;"+FileKey+"</td>\n");
    break;
    case ".html":   
    sb.Append("<td><img src=\"images/html.gif\">&nbsp;" + DownPath +  "&nbsp;<a href="+sURL+" target=\"_blank\"><img src=\"images/ie.gif\" width=16 height=16 border=0 alt=\"浏览\"></a>&nbsp;<a href=\"editfile.aspx?name=" +editname+"&type=file\"><img src=\"images/edit.gif\" width=16 height=16 border=0 alt=\"编辑\"></a>&nbsp;\n&nbsp;"+FileKey+"</td>\n");
    break;  .................................
    按不同的后缀名生成不同的样式就是啦
      

  8.   

    以前做一个防盗链的媒体播放程序:private void Page_Load(object sender, System.EventArgs e)
    {
    SongStoreInfo ssi;
    int id; //歌曲ID
    HttpCookie myCookie = new HttpCookie("CanRead");
    myCookie = Request.Cookies["CanRead"];

    //如果直接访问页面页面时
    if (myCookie == null)
    {
    Response.Redirect("http://www.cwestc.com");
    }
                
    id = int.Parse( Request.Params["ID"]); SongStore ss = new SongStore();
    ssi = ss.GetDetails(id);

    Configuration.ModuleSettings settings = Configuration.ModuleConfig.GetSettings(); FileInfo file = new System.IO.FileInfo(settings.SongPhysicsPrefix + ssi.SongUrl);

    // 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

    /*FileStream fs = file.Open(FileMode.Open);

    BinaryReader br = new BinaryReader(fs);*/
    string  fileName = file.Name.ToLower();
    int lastIndex = fileName.LastIndexOf(".");
    fileName = fileName.Substring(lastIndex); // 根据文件后缀指定文件的Mime类型
    switch (fileName)
    {
    case ".ppt":
        Response.ContentType = "application/ppt";
        break;
    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;
    case ".wma":
    Response.ContentType = "video/x-ms-wma";
    break;
    default:
    Response.ContentType = "application/octet-stream";
    break;
    } Response.Charset = "UTF-8"; // send the file stream to the client
    int length = (int) file.Length;
    /*Response.BinaryWrite(br.ReadBytes(length));*/
    Response.WriteFile(file.FullName);
    // flush the execution of this page
    Response.End();
    /*Response.Clear();*/
    // stop the execution of this page
    /*br.Close();
    fs.Close();*/
      

  9.   


    gasover(无尽) 讲的好像是直接下载的,并不是在线浏览的吧,我也遇到在线浏览的困惑,不同文件类型如何调用指定软件打开啊