Public Class Form1
Dim fn As String
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If My.Computer.FileSystem.ReadAllText(fn, System.Text.Encoding.UTF8).Trim = "" Then Exit Sub
d.Rows.Clear()
For Each h As String In My.Computer.FileSystem.ReadAllText(fn, System.Text.Encoding.UTF8).Split(vbNewLine)
If h.Trim = "" Then Exit For
d.Rows.Add(h.Split("|")(0), h.Split("|")(1), h.Split("|")(2))
Next
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
IO.File.Delete(fn)
For Each row As DataGridViewRow In d.Rows
If row.IsNewRow Then Exit For
My.Computer.FileSystem.WriteAllText(fn, row.Cells(0).Value & "|" & row.Cells(1).Value & "|" & row.Cells(2).Value & vbNewLine, True, System.Text.Encoding.UTF8)
Next
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
fn = CurDir() & "\t.txt"
If IO.File.Exists(fn) = False Then
IO.File.Create(fn).Close()
End If
End Sub
End Class