如何使用代码下载txt文件 [英] How to download txt file using code
本文介绍了如何使用代码下载txt文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Windows窗体。如何在按钮点击事件上使用vb.net代码下载文本文件
解决方案
关于WebClient.DownloadFile
< quote>将具有指定URI的资源下载到本地文件。
编码:
Friend Sub Button_Click(ByVal sender as Object,ByVal e as EventArgs)Handles Button.click
Dim wc as System.Net.WebClient
Dim Localfile as String =PathOfLocalFile.ext;
Dim Remotefile as String =UrlOfRemoteFile.ext;
wc.DownloadFile(RemoteFile,LocalFile)
End Sub
你可以使用我的完整但是简短的下载应用程序作为样本。我在过去的答案中提供了完整的源代码:
如何从互联网上下载文件 [ ^ ]。
另见我过去的答案:
FTP:下载文件 [ ^ ],
如何从Asp.net 2.0中的服务器下载文件 [ ^ ]。
-SA
Hi,i am working on windows form .How to download text file using vb.net code on button click events
解决方案MSDN Info about WebClient.DownloadFile
<quote>"Downloads the resource with the specified URI to a local file."
Coding this:
Friend Sub Button_Click(ByVal sender as Object, ByVal e as EventArgs) Handles Button.click Dim wc as System.Net.WebClient Dim Localfile as String = "PathOfLocalFile.ext"; Dim Remotefile as String = "UrlOfRemoteFile.ext"; wc.DownloadFile(RemoteFile, LocalFile) End Sub
You can use my complete but short downloading application as a sample. I provided full source code in my past answer:
how to download a file from internet[^].
See also my past answers:
FTP: Download Files[^],
how to download a file from the server in Asp.net 2.0[^].
—SA
这篇关于如何使用代码下载txt文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文