|
-
Sep 17th, 2007, 07:43 AM
#1
Thread Starter
Addicted Member
[RESOLVED] [2005] Error streamreading number of lines in text file
Hello,
A utility I have written is causing an OutOfMemory exception error on the following line:
Code:
System.Text.RegularExpressions.Regex.Split(myStreamChecker.ReadToEnd(), Environment.NewLine).Length
The utility works in the majority of cases, but the text file I am reading on this occasion is huge in comparison to the others that the utility is generally used for - 692,684KB, whereas it is normally asked to look at files below 145,000KB.
All the line is doing is assigning a "maximum" value to a variable so that it may use it in a progress bar as it reads each line.
Is there a better way of doing what I want to do, or does anybody have an advice regarding the type of variable I should be assigning the value to? I've tried the full range of "Int"'s, to no avail. At the time of writing, the variable is an Int64.
The full error text is:
Exception of type 'System.OutOfMemoryException' was thrown.
at System.String.GetStringForStringBuilder(String value, Int32 startIndex, Int32 length, Int32 capacity)
at System.Text.StringBuilder.GetNewString(String currentString, Int32 requiredLength)
at System.Text.StringBuilder.Append(Char[] value, Int32 startIndex, Int32 charCount)
at System.IO.StreamReader.ReadToEnd()
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
|