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
여기에 질문이있을 것 같지 않습니다. – JohnFx