2011-12-17 63 views
0

我正在使用應用程序服務器來調用Oracle Reports,並且當調用報告時服務器將url轉換爲pdf時,我有url調用報告,但是當報告包含大量數據時,很多時間加載。我想在asp.net中做,當我打電話給報告的URL它打開PDF文件,並將其複製到我的網頁文件夾的根,下一次,當我打電話的URL它打開PDF文件和在後臺加載使用vb.net在asp.net中複製文件

先生,我想在新標籤頁中呼籲hyerplink功能,請告訴我的解決方案,

先生根據我的問題我想用多線程調用從根目錄和其他一個文件在後臺下載

+0

似乎沒有在這裏是一個問題。 – JohnFx 2011-12-17 03:58:36

回答

1

您可以使用WebClient類。

WebClient client = new WebClient(); 
client.DownloadFile(Uri, fileName); 

VB

Dim client As New WebClient 
client.DownloadFile(Uri, fileName) 

編輯:

第一個參數指定源文件的位置。第二個參數是目標文件的路徑。如果將它保存在web-app的根目錄下,請使用Server.MapPath()方法獲取絕對路徑。

標記:

<form id="form1" runat="server"> 
    <div> 
     <asp:Button ID="Button1" runat="server" Text="Button" /> 
     <asp:HyperLink ID="HyperLink1" Visible="false" Target="_blank" runat="server">HyperLink</asp:HyperLink> 
    </div> 
</form> 

代碼:

Protected Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click 
     Dim client As New WebClient 
     Dim muri As New Uri("http://your_url") 
     Dim destPath = Server.MapPath("~/file.pdf") 
     client.DownloadFile(muri, destPath) 
     HyperLink1.Visible = True 
     HyperLink1.NavigateUrl = "~/file.pdf" 
     HyperLink1.Text = "Open" 
    End Sub 
+0

什麼是這裏的uri和我從哪裏下載文件的地方寫網址 – 2011-12-17 07:03:28