hi Techie's,
1) Does StreamReader.ReadToEnd method loads the entire file line by line through a "while loop" internally
2) RegEx when searching the string, does it search/scan the file using the "while loop" internally
i have 2 codes doing the same thing, if i know the method which is faster when seraching the text in double quotes inside the file(s), i would be using the same for better performance.
the following code is actually scanning the files for the string in double quotes and would get me the list accordingly in a collection and then the collection is looped to insert the values into the database
Dim regularExpression As Regex = New Regex(sVBPattern)
Dim matchResult As MatchCollection
Dim sPattern As String = sVBPattern
Dim fs As New FileStream(sFilePath, FileMode.Open, FileAccess.Read)
Dim objtxtrdr As TextReader
objtxtrdr = File.OpenText(sFilePath)
Dim text As String = objtxtrdr.ReadToEnd()
matchResult = regularExpression.Matches(
Text)
Dim objMatch As Object
For Each objMatch In matchResult
' Console.WriteLine(objMatch
) '************** insert query needs to be written***********
'*************************
**********
******
InsertInDB(sFile.Substring
(sFile.Las
tIndexOf("
\") + 1), sFilePath, objMatch.tostring, sPattern)
Next
'*************************
****code 2*************************
**********
Do
line = sr.ReadLine()
'same code for regularExpression checking and matching and then inserting in to the database
'regular expression checking would be done with the help of IsMatch method and Match, NextMatch
i += 1
Loop Until line Is Nothing
Thanks,
M.Naveen Swamy
Start Free Trial