开发学院手机开发Windows Mobile 开发 Window mobile读取text文件的内容 阅读

Window mobile读取text文件的内容

 2010-08-22 13:10:00 来源:WEB开发网   
核心提示:读取utf8格式的文本Imports SystemImports System.IOImports System.TextPublic Class Form1Dim lujingapp As StringPrivate Sub Button1_Click(ByVal sender As System.Object, B

读取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

Tags:Window mobile 读取

编辑录入:coldstar [复制链接] [打 印]
[]
  • 好
  • 好的评价 如果觉得好,就请您
      0%(0)
  • 差
  • 差的评价 如果觉得差,就请您
      0%(0)
赞助商链接