vb.net中,读取和写入文件
1个回答
2014-02-20
展开全部
写入:Dim sr As New IO.StreamWriter(Application.StartupPath & "/写入的文本.txt")
sr.WriteLine("写入的内容") sr.Close()读取:If (File.Exists(Application.StartupPath & "/msg.txt")) Then
Dim fm As New IO.FileStream(Application.StartupPath & "/读取的文本.txt", FileMode.Open)
Dim sr As IO.StreamReader = New IO.StreamReader(fm)
Do While sr.Peek() >= 0
TextBox1.Text = sr.ReadLine() (读取文本到文本框)
Loop end if
sr.WriteLine("写入的内容") sr.Close()读取:If (File.Exists(Application.StartupPath & "/msg.txt")) Then
Dim fm As New IO.FileStream(Application.StartupPath & "/读取的文本.txt", FileMode.Open)
Dim sr As IO.StreamReader = New IO.StreamReader(fm)
Do While sr.Peek() >= 0
TextBox1.Text = sr.ReadLine() (读取文本到文本框)
Loop end if
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询