Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8889943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:23:13+00:00 2026-06-14T22:23:13+00:00

I have a code to retrieve an XML file from the site, so I

  • 0

I have a code to retrieve an XML file from the site, so I do as follows:

WebRequest request = WebRequest.Create(url);
request.Method = "GET";
request.ContentType = "text/xml";

using (WebResponse webResponse = request.GetResponse())
{
    using (Stream responseStream = webResponse.GetResponseStream())
    {
       if (responseStream != null)
        {
            reportXML = XDocument.Load(responseStream.ToString());
        }
    }
    using (XmlWriter writer = XmlWriter.Create(@"C:\Retrieved.xml"))
    {
        reportXML.Save(writer);
    }
 }

But I debugged the app and it seems I lose everything on this line of code, so I have nothing anymore to save.

Stream responseStream = webResponse.GetResponseStream())

Any idea why it could be?

If I investigate the object I see this:

Length = ‘responseStream.Length’ threw an exception of type
‘System.NotSupportedException’

And the error is following:

Could not find file ‘C:\Documents and Settings\user\My
Documents\Visual Studio
2010\Projects\Proto\App\bin\Debug\System.Net.ConnectStream’.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T22:23:14+00:00Added an answer on June 14, 2026 at 10:23 pm

    This is the problem:

    reportXML = XDocument.Load(responseStream.ToString());
    

    Calling ToString() on a stream like that is pretty much never going to give you anything useful. If you just want to load the contents of the stream, get rid of the ToString call:

    reportXML = XDocument.Load(responseStream);
    

    Alternatively, if you really just want to save it to disk, simply use Stream.CopyTo and don’t bother parsing it as XML in the first place.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the next code to retrieve some data from a xml file. The
I have generated a XML file automatically from the below code. if (isset($_POST[song])&& $_POST['song']
I have some code to retrieve XML data: import cStringIO import pycurl from xml.etree
To get this XML file: <?xml version=1.0 encoding=UTF-8?> <root> <command action=retrieve id=1234 code =
I have created a simple method to retrieve XML output from an HTTPService and
I am using the following code to retrieve data from the xml file. It
HI i have a peice of code which takes information from a xml file
I have the following code, which will retrieve a filename from a table and
I have the following code to retrieve a dataset from a database. I would
I need to retrieve some details from a MusicXML (xml) file in Java. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.