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

VS 2008 Reading file. Problem with finding and adding a string.

$
0
0
Hello !

The problem is that I can't add a new string to the files.
So the file contains configurations.
File looks like that:

# example1
IDE example1.1
IDE example1.2
IDE example1.3
IDE example1.4
...
# example2

IDE example2.1
IDE example2.2
IDE example2.3
IDE example2.4
...

# map files <- this is what i need(i can find it, but ...)
IDE map files1
IDE map files/files/something
IDE map files/something
IDE map files/string (they don't always contain numbers ... at the end ...)
...
IDE map files(last) <- so i need to find the lattest of this one ... and after that I need to add my string in a new line ... for example: "IDE map filestest" , after that file should continue as it was ...

#
# example 3
...

My code looks like that(long time ago i found it and a bit edited):

Private Sub read_files(ByVal file_location As String)
Dim dat_item As String = "# map files"
Dim fileIn As New StreamReader(file_location)
Dim strData As String = ""
Dim lngCount As Long = 1
While (Not (fileIn.EndOfStream))
strData = fileIn.ReadLine()
If strData = dat_item Then
'here should be something
Else
lngCount = lngCount + 1
End If
End While
End Sub

Viewing all articles
Browse latest Browse all 27554

Trending Articles



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