So I have spent a few days now stuck on this problem. I have a file, at the offset &hd026 there is a name. This name can be any amount of characters long, this part is easy, already have something to do this and saves it into a textbox. Now there is another instance of this name a varying offset somewhere else in the file. I need a way to find the offset of the second name that is fast and easy to do.

Any tips, hints or help would be greatly appreciated.

What exactly are you looking to have returned? (the entire line, the index of where the word starts etc) I can show you many different ways to search text but do you have a specific key word to search for?

One example:

Private Function IsFileContainsSrting(ByVal SearchWord As String, ByVal FileName As String) As Boolean
        Dim IsWordFound As Boolean = False
        Dim FileContents As String = String.Empty
        Dim FileStreamReader As StreamReader
            FileStreamReader = New StreamReader(FileName)
            FileContents = FileStreamReader.ReadToEnd()
        Catch ex As Exception
            IsWordFound = False
            If FileStreamReader IsNot Nothing Then FileStreamReader.Close
        End Try

        If FileContents.IndexOf(SearchWord) > 0 Then
            'IndexOf returns -1 of not found and 0 if the textVal is empty
            IsWordFound = True
        End If

        Return IsWordFound

    End Function

Also there is the RegEx class that is very fast but more complicated to first start learning/using.

I need the position of it for the binary reader so I could write hex bytes to a position a specific number of bytes away from the offset of the last instance of the name.

This article has been dead for over six months. Start a new discussion instead.