How to read a string in another string where between Starting Index and first-encountered Ending Index
I have one giant file which contains info for each customers and they seperated the customers info with Starting and Ending Indexes and I need to get a specific customer info to display.
Dim oFile As New FileInfo(sFileName)
Dim sFileContent As String = oFile.OpenText().ReadToEnd()
Dim iStartIndex As Integer = sFileContent.IndexOf(roNotification.StartByte)
Dim iEndIndex As Integer = sFileContent.IndexOf(roNotification.EndByte, iStartIndex)
Dim sCustomerInfo As String = sFileContent.Substring(iStartIndex + roNotification.StartByte.Length - 1, iEndIndex)
Nothing much tho. But it reads the file and put that giant file into sFileContent variable. I am not sure how efficient this way is (seems worse than MemoryStream).
Index strings can be more than 1 character.
Edit:
More info about the file, the file contains only one giant line and that lines contains all the info. I cannot touch on that file except for reading it since it has really confidential data.
I am looking for the string between Starting Index and First-encountered Ending Index exclusively.
You should read the file line-by-line:
This way, you’ll never have more than one line in memory at a time.