【VB.net自学笔记(三)】StreamReader与StreamWriter的应用——UTF-8文本的读写

来源:互联网 发布:银行业杠杆率数据 编辑:程序博客网 时间:2024/05/22 07:43

StreamReader,属于System.IO的子类。

Function SRead(path As String)'输入文件的路径Dim txt As System.IO.StreamReaderDim st As Stringst = ""txt = New StreamReader(path)st = txt.ReadToEndSRead = stend function

StreamWriter,属于System.IO的子类。

Sub SWrite(txt As String, path As String, filename As String) '一次性输出文本Using logObject As StreamWriter = New StreamWriter(path & "\" & filename )logObject.Write(txt)logObject.Close()End UsingEnd Sub

Sub LWrite(txt As string, path As string, filename As String) '逐行输出Dim nowtimeUsing logObject As StreamWriter = File.AppendText(path & "\" & filename )logObject.WriteLine(txt)logObject.Close()End UsingEnd Sub


阅读全文
0 0
原创粉丝点击