简体   繁体   English

使用vb.net在asp.net中进行文件复制

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

I am Using a Application server for calling Oracle Reports and i have url to call the report when report is called the server convert it into pdf but when report contain large data it got a lot of time to load.I want to do in asp.net that when i call the report url it open the pdf file and copies it into the root of my web folder and next time when i call the url it open the pdf file and on back end loads the 我正在使用应用程序服务器调用Oracle Reports,并且当调用报告服务器将其转换为pdf时,我具有URL来调用该报告,但是当报告包含大量数据时,需要花费很多时间来加载。净,当我调用报告url时,它会打开pdf文件并将其复制到我的网络文件夹的根目录中;下次,当我调用url时,它会打开pdf文件并在后端加载

Sir I want to call function on hyerplink in new tab please tell me solution for that 先生,我想在新标签页中的hyerplink上调用函数,请告诉我解决方案

Sir According to My question i want to use multithreading to call one file from root directory and other to download on backend 先生根据我的问题,我想使用多线程从根目录中调用一个文件,并在后端下载另一个文件

You may use WebClient class. 您可以使用WebClient类。

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

VB VB

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

EDIT: 编辑:

The first argument specify the location of source file. 第一个参数指定源文件的位置。 The second argument is a path of destination file. 第二个参数是目标文件的路径。 Use Server.MapPath() method to get absolute path if you save it at root of web-app. 如果将它保存在Web应用程序的根目录中,请使用Server.MapPath()方法获取绝对路径。

Markup : 标记:

<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>

Code: 码:

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