专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > VB Dotnet

基础有关问题:关于读取文本文件

发布时间:2011-06-23 14:47:16 文章来源:www.iduyao.cn 采编人员:星星草
基础问题:关于读取文本文件
小弟业余爱好自己写点小程序自用,以前用VB6,现在想学学.net

  Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
  With OpenFileDialog2
  .Filter = "桩号文件(.txt)|*.txt"
  .FilterIndex = 1
  .ShowDialog()
  End With
  Dim ZhhaoFile As String
  ZhhaoFile = OpenFileDialog2.FileName
  Dim objFile As New System.IO.StringReader(ZhhaoFile)
  Dim StrContents As String
  StrContents = objFile.ReadToEnd()
  objFile.Close()
  objFile.Dispose()
  TextBox1.Text = StrContents
  End Sub

请问这段代码,最后的textbox1里面得到的为什么是路径?譬如"c:\text.txt"之类,而不是文件内容。

要怎样才能读取文本文件内容?

谢谢!

------解决方案--------------------
不应该用StringReader而应该用StreamReader,StringReader会把一个字符串当作流来读取。
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: