cara menghapus string di dalam text file menggunakan vb.net
selamat pagi,. sesuai dengan judul yang saya posting saya akan berbagi tentang cara menghapus string atau tulisan pada text file yang tidak dibutuhkan , khususnya untuk vb.net
ini scriptnya :
Try
Dim lines As List(Of String) = System.IO.File.ReadAllLines(My.Application.Info.DirectoryPath & "\sms-msg.txt").ToList
For Each line As String In lines
Dim dts() As String
dts = line.Split("|")
If dts(1) = str Then
id_sms_from = dts(0)
id_sms_to = dts(1)
isi_sms = dts(2)
lines.Remove(line)
Exit For
End If
Next
System.IO.File.WriteAllLines(My.Application.Info.DirectoryPath & "\sms-msg.txt", lines)
Catch ex As Exception
End Try
silahkan di coba
ini scriptnya :
Try
Dim lines As List(Of String) = System.IO.File.ReadAllLines(My.Application.Info.DirectoryPath & "\sms-msg.txt").ToList
For Each line As String In lines
Dim dts() As String
dts = line.Split("|")
If dts(1) = str Then
id_sms_from = dts(0)
id_sms_to = dts(1)
isi_sms = dts(2)
lines.Remove(line)
Exit For
End If
Next
System.IO.File.WriteAllLines(My.Application.Info.DirectoryPath & "\sms-msg.txt", lines)
Catch ex As Exception
End Try
silahkan di coba
Komentar
Posting Komentar