Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27192

VS 2010 [RESOLVED] How to find data and delete it from a text file

$
0
0
Hi all,

What I'm trying to do is select data from CheckedListBox1.SelectedItem and then search C:\in.txt for that line and delete it entirely.

I've tried the replace command, but isn't doing want I need as it doesn't remove the entire line as it doesn't remove the carriage return. So when I look back at the CheckedListBox1 it still shows a check box (albeit no data is there). Is there an easy way to do what I want or can I modify the code I'm using below to remove the carriage return somehow?

Code:

Dim TheFile As String = "c:\in.txt"
        File.WriteAllText(TheFile, File.ReadAllText(TheFile).Replace(CheckedListBox1.SelectedItem, ""))


Viewing all articles
Browse latest Browse all 27192

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>