7*24小时应急电话:15927160396
首页 新闻资讯 技术文章
Window mobile读取text文件的内容

  读取utf8格式的文本

  Imports System

  Imports System.IO

  Imports System.Text

  Public Class Form1

  Dim lujingapp As String

  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

  Dim strutf8 As String

  Dim myreader As StreamReader

  myreader = System.IO.File.OpenText(lujingapp & "test.txt")

  strutf8 = myreader.ReadToEnd

  TextBox1.Text = strutf8

  End Sub

  Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

  lujingapp = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly.GetName.CodeBase)

  lujingapp = lujingapp & "\" '获取当前路径

  End Sub

  End Class

  读取普通的文本

  Imports System

  Imports System.IO

  Imports System.Text

  Public Class Form1

  Dim lujingapp As String

  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

  Dim str As String

  Dim myfilestream As FileStream

  Dim myreader As StreamReader

  myfilestream = System.IO.File.OpenRead(lujingapp & "test.txt")

  myreader = New StreamReader(myfilestream, Encoding.Default)

  str = myreader.ReadToEnd

  TextBox1.Text = str

  End Sub

  Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

  lujingapp = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly.GetName.CodeBase)

  lujingapp = lujingapp & "\" '获取当前路径

  End Sub

  End Class

版权所有:武汉网福互联科技有限公司    鄂ICP备09022096号
业务QQ:23444550 客服QQ:267052100 电邮:23444550@qq.com  

鄂公网安备 42010602000905号

手机站二维码