property Value as string
get
if File.Exists("你的文件")=False then return "" '如果文件不存在 返回空
Dim fo As New IO.StreamReader("你的文件")
Dim text As String = fo.ReadToEnd
fo.Close()
return text
end get
set (value as string)
Dim fw As New IO.FileStream("你的文件", FileMode.OpenOrCreate, FileAccess.Write)
Dim b() As Byte = Encoding.UTF8.GetBytes(text)
fw.Write(b, 0, b.Length)
fw.Close()
end set
end property
你只要调用一下就可以了
value=textbox1.text '就保存了
textbox1.text=value ' 读取文件了