|
-
Feb 4th, 2007, 03:26 PM
#1
Thread Starter
Member
Erase a single line from a text file?
Hey all,
I am writing a program that protects selected folders of your choice with a password. Going great so far, I was almost done, then I ran in to a problem.
The last thing that I need to complete is this:
I want the end user to be able to delete a directory. I am using a simple text file (that I change the extension to .dll for security purposes) to store the information of which directories to protect. The program reads from that file line by line to deterime which directories to protect.
There is a lot of code so I won't post it all, but I will post the section that I am working on.
Note, in the code that I have figured out how to match and find the line that I want to delete, I just don't know how to delete it.
VB Code:
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim fcontent() As String = Split(My.Computer.FileSystem.ReadAllText("C:\Program Files\Folder Protection\fld.dll"), vbCrLf) 'file from which to read text
For a As Integer = 0 To UBound(fcontent) 'reads the array of text lines
If String.Compare(fcontent(a), TextBox1.Text) = 0 Then 'compares the lines of text to the text in textbox1
'CODE TO DELETE LINE HERE!!!
Else : MsgBox("Directory not found!")
End If
Next
End Sub
Thank You,
Michael Ifland
Visual Basic.NET 2005
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|