2013-12-16 84 views
0

我正在開發KnoweldgeBase/Library,其中的頁面列出了與所選主題相關的PDF和Word文檔。這些文件被上傳到URL爲「/Interface/AdminUploads/Miscellaneous/FILENAME」的文件夾中。通過點擊按鈕打開PDF或Word文檔

我經過其中的每一行有文件類型的圖像,然後將文件標題,然後公佈日期(通過另一頁的所有創建)一個表格,列出了文件。當我點擊文檔的圖像時,如何打開PDF或Word文檔?

回答

0

試試此代碼。

  string filepath ="/Interface/AdminUploads/Miscellaneous/FILENAME"; // Full Path of Pdf. 
      WebClient client = new WebClient(); 
      Byte[] buffer = client.DownloadData(filepath); 

      Response.ContentType = "application/pdf"; 
      Response.AddHeader("content-length", buffer.Length.ToString()); 
      Response.BinaryWrite(buffer); 


      Response.Flush(); 
      Response.End(); 
0

嘗試簡單的代碼

Response.Write(string.Format("<script>window.open('{0}','_blank');</script>", "pdflocation/" + "Example.pdf")); 
0

我得到它的通過工作...

System.Diagnostics.Process.Start(@fileLocation); 

運行此在圖像點擊並傳入變量'fileLocation'的方法中的代碼;