What are you doing with this Xml that you need to read it into a string? Read it into an XmlTextReader or an XmlDom to do something useful with it. XmlReader will read only a chunk at a time so it's very memory efficient but parsing is a bit difficult.
There is no reason that I can think of to load Xml into a string.
+++ Rick ---
>>The string Length property is an int, which can be up to the max value of an int32, I believe (something like 2,000,000,000 characters)
>>
>>What are you trying to read in?
>
>I was doing something like this:
>
>
>lcXml = lcStreamReader.ReadToEnd()
>
>
>lcXml is defined as a String. lcStreamReader is containing a dataset which has been converted into a XML and then to it. At that point, I already changed the code to use a string builder approach instead of lcXml. With the lcXml, this is giving me an OutOfMemory exception. I have about 7000 records which contain a lot of fields in that dataset. If I have a little less than that, I am not running into the OutOfMemory exception. With the change of code, I did not have the time to test if this will help so far.
>
>Here is the ReadToEnd() stack:
>
>
>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()
>