3

vb.net Web アプリで html ファイルをローカルにダウンロードするプロセスを作成する必要があります。私は現在使用していwebClient.DownloadFileます:

Dim myWebClient As New System.Net.WebClient
myWebClient.DownloadFile("http://archive.ncsa.illinois.edu/primer.html", _
                        "C:\test.html")

ユーザーがファイルを保存する場所を選択できるように、代わりに「名前を付けて保存」ウィンドウでこれを行う組み込みの方法はありますか? それとも自分で書く必要がありますか?

4

3 に答える 3

5

使用できます

Response.AddHeader("Content-Disposition", "attachment;filename=testfile_file.html");
Response.Write or Response.WriteFile
于 2011-05-13T10:16:21.393 に答える
1

これはあなたの質問に対する答えではないことは承知していますが(トーマスの答えのコメントを参照)、単純に保つことが良い方法である場合があります

Please right-click this link and save the file
<a href=""http://archive.ncsa.illinois.edu/primer.html">HTML Primer</a>
于 2011-05-13T10:23:25.243 に答える
0

以下のコードを試してください

Response.ContentType = "report/rpt";

Response.AppendHeader("Content-Disposition", "attachment; filename=CrystalReport1.rpt");

Response.TransmitFile(Server.MapPath("CrystalReport1.rpt"));

Response.End();
于 2011-05-13T10:19:49.400 に答える