VB.net 文件读取、写入、追加操作
作者:admin 日期:2020-11-14
Imports System.IO
Dim PathUserData As String = Application.StartupPath & "\实操统计sql.txt"
TextTB.Text = System.IO.File.ReadAllText(PathUserData)
‘或者用 System.IO.File.ReadAllText(PathUserData, System.Text.Encoding.UTF8)
上面这个是读取
System.IO.File.ReadAllText(PathUserData, System.Text.Encoding.UTF8) 此用法是把编码方式转为UTF8
写入如下:
Dim PathUserData As String = Application.StartupPath & "\实操统计sql.txt"
Dim t As System.IO.StreamWriter = New System.IO.StreamWriter(PathUserData, True, System.Text.Encoding.UTF8)
t.Write(TextTB.Text)
t.Close()
追加如下:
Dim PathUserData As String = Application.StartupPath & "\实操统计sql.txt"
Dim t As System.IO.StreamWriter = New System.IO.StreamWriter(PathUserData, True, System.Text.Encoding.UTF8)
t.WriteLine(TextTB.Text)
t.Close()
同样的,你可以把
System.Text.Encoding.UTF8
下一篇: vb.net 日期时间格式转换(Format函数)
文章来自: 本站原创
引用通告: 查看所有引用 | 我要引用此文章
Tags: vb.net
相关日志:
广告位