VB.NETç¼ç¨è¯»åtxtææ¬ææ¡£ä¸çæ°æ®ï¼å¹¶ææ°æ®ä¿å为æ°ç»ï¼ä»£ç å¦ä¸ï¼
'åé
件æ件
Private Sub saveIni(ByVal filePath As String, ByVal str As String)
Dim sw As StreamWriter = New StreamWriter(filePath, True) 'trueæ¯æ以追å çæ¹å¼æå¼æå®æ件
sw.WriteLine(str)
sw.Flush()
sw.Close()
sw = Nothing
End Sub
'读é
件æ件
Private Function readIni(ByVal filePath As String)
Dim iniDt As New DataTable
iniDt.Columns.Add("text")
iniDt.Columns.Add("value")
Try
Dim sr As StreamReader = New StreamReader(filePath, System.Text.Encoding.Default)
Dim line As String = ""
While Not sr.EndOfStream
Dim str = sr.ReadLine()'读åå½åè¡
iniDt.Rows.Add(New String() {
str(0),
str(1)
})
End While
sr.Close()
sr = Nothing
Catch ex As Exception
End Try
Return iniDt
End Function