vb.net读写文本文件简单示例

Dim strFilePath As String =SaveFileDialog1.FileName
Dim sw As StreamWriter = New StreamWriter(strFilePath, True)  'true是指以追加的方式打开指定文件  
For i = 0 To j  
temp 
= i.ToString  
sw.WriteLine(temp)  
sw.Flush()  
Next  
sw.Close()  
sw 
= Nothing 

 

 

 

Dim line As String  
Dim sr As StreamReader = New StreamReader(strPath, System.Text.Encoding.Default)  
Do While sr.Peek() > 0  
line 
= sr.ReadLine()  
Loop  
sr.Close()  
sr 
= Nothing '构造函数new  
Public Sub New(Path, Encoding)

 

posted on 2011-09-20 14:49  Konimeter  阅读(10280)  评论(0编辑  收藏  举报