Window mobile读取text文件的内容
来源:
发布时间:2010/8/28
浏览次数:1077
读取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