簡體   English   中英

使用vb.net在asp.net中進行文件復制

[英]File Copying in asp.net using vb.net

我正在使用應用程序服務器調用Oracle Reports,並且當調用報告服務器將其轉換為pdf時,我具有URL來調用該報告,但是當報告包含大量數據時,需要花費很多時間來加載。凈,當我調用報告url時,它會打開pdf文件並將其復制到我的網絡文件夾的根目錄中;下次,當我調用url時,它會打開pdf文件並在后端加載

先生,我想在新標簽頁中的hyerplink上調用函數,請告訴我解決方案

先生根據我的問題,我想使用多線程從根目錄中調用一個文件,並在后端下載另一個文件

您可以使用WebClient類。

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

VB

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

編輯:

第一個參數指定源文件的位置。 第二個參數是目標文件的路徑。 如果將它保存在Web應用程序的根目錄中,請使用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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM