[置顶] 读取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;  
}


原文地址:https://www.cnblogs.com/wsq724439564/p/3258228.html