WebClientクラスを使用できます。
WebClient client = new WebClient();
client.DownloadFile(Uri, fileName);
VB
Dim client As New WebClient
client.DownloadFile(Uri, fileName)
EDIT:
最初の引数は、ソースファイルの場所を指定します。 2番目の引数は、宛先ファイルのパスです。 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