版权声明:未经允许禁止转载,否则会计入黑名单:http://www.cnblogs.com/123it/p/copyright.html

注意:已授权bilibili用户wy14abcd转载!

(已修改为VS(而不仅仅是VS2015))

最近要从一个http上下载个文件,差点就直接telnet了,突然发现了这个:

 My.Computer.Network.DownloadFile("目标文件网址")

但是还得读取它,用什么呢?

直接用

 Imports System.IO             '引入System.IO命名空间
Dim test As New StreamReader("读取文件的路径")

但是在类里,不能用Application.StartupPath代表程序所在目录呀,这怎么办呢?遂baidu了一下,发现可以这样:

 My.Application.Info.DirectoryPath          '=Application.StartupPath

然后,就可以读取了。

完整代码:(目标文件地址http://123it.cf/test/download.txt

 Imports System.IO        '引入System.IO命名空间

 Public Class test

 Private Sub frm_test_Load(sender As Object, e As EventArgs) Handles MyBase.Load
My.Computer.Network.DownloadFile("http://123it.cf/test/download.txt", My.Application.Info.DirectoryPath & "\" & "down.txt") '下载文件
Dim rreeaadd As New StreamReader(My.Application.Info.DirectoryPath & "\" & "down.txt")
MsgBox(rreeaadd.ReadtoEnd,,"提示") '读取文件内容并弹出Msgbox消息框
rreeaadd.Close() '关闭流
End Sub End Class

最新文章

  1. 模仿iframe框架,由分隔栏动态改变左右两侧div大小———基于jQuery
  2. Linux 传输文件
  3. linuxMint設置窗口最大最小化
  4. 《深入浅出WPF》笔记一
  5. C#下调用C++ SDK的编码常识
  6. jQuery插件 -- 表单验证插件jquery.validate.js, jquery.metadata.js
  7. Girls: different perspectives to consider
  8. 20141109--SQL 练习题-1
  9. HTML5 Video与Audio 视频与音频
  10. http请求的cookie
  11. effective c++ 条款10 handle assignment to self operator =
  12. linux command----vi
  13. Ceph和Openstack的cinder模块对接方法
  14. OAuth授权 | 把这一篇丢给他
  15. Adversarial Examples for Semantic Segmentation and Object Detection 阅读笔记
  16. websocket 与 tornado 的结合
  17. OSWatcher使用过程中小问题解决方法
  18. 【2018.10.11 C与C++基础】C Preprocessor的功能及缺陷(草稿)
  19. RXD, tree and sequence IN HDU6065
  20. List进行排序

热门文章

  1. css(二) block,inline和inline-block概念和区别
  2. jsoup的介绍使用(转)
  3. C语言-结构体
  4. UOJ #192 【UR #14】 最强跳蚤
  5. Java的三种代理模式
  6. magento中文语言包的使用
  7. PHP 递归实现层级树状展现数据
  8. Java Des加解密方法(c#加密Java解密)
  9. --@angularJS--指令与控制器之间较复杂的交互demo2
  10. Java div 使用说明