[置顶] 读取pdf并且在web页面中显示

读取pdf并且在web页面中显示

if (System.IO.File.Exists(f))  
 {  
        Response.ContentType = "applicationpdf";  
        System.IO.FileStream reader = System.IO.File.OpenRead(f);  
        byte[] data = new byte[reader.Length];  
        reader.Read(data, 0, (int)reader.Length);  
        reader.Close();  
        Response.OutputStream.Write(data, 0, data.Length);  
        Response.Flush();  
        //Response.End();  
        return;  
 }  
 else  
{  
        //没有找到pdf                                   
        Response.Write("没有找到相应文件");  
        // Response.End();  
        return;  
}


posted @ 2013-07-02 21:54  shouqiang Wei  阅读(623)  评论(0编辑  收藏  举报