Microsoft KB Archive/929265

= You may receive a COMException exception when you use the &quot;SPWeb.GetFileAsString(URL)&quot; method to obtain an XML file in Windows SharePoint Services =

Article ID: 929265

Article Last Modified on 12/27/2006

-

APPLIES TO


 * Microsoft Windows SharePoint Services

-



SYMPTOMS
When you use the SPWeb.GetFileAsString(URL) method to obtain an XML file in Microsoft Windows SharePoint Services, you may receive a COMException exception.



CAUSE
This issue occurs when the size of the XML file is larger than 10 megabytes (MB).



WORKAROUND
To work around this issue, use the SPFile.OpenBinary method instead of the SPWeb.GetFileAsString(URL) method. The following code sample contains the SPFile.OpenBinary method. SPWeb web = new SPSite(&quot;&quot;).OpenWeb; SPFile file = web.GetFile(&quot;&quot;); //web.GetFileAsString(&quot;&quot;); // This line may generate a COMException exception if the size of the XML file is larger than 10 MB. byte[] content = file.OpenBinary; System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding; string strContent = enc.GetString(content); MessageBox.Show(strContent);

Additional query words: WSS

Keywords: kbexpertiseinter kbtshoot kbprb KB929265

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.