Solved

Save HttpWebResponse XML file to Local Computer

Posted on 2007-11-15
2
1,125 Views
Last Modified: 2013-11-26
Hi,

I "get" (download) a XML file using the code listed below.

How can I save that to a local file? For the life of me I can't figure it out.

Thanks
Dim wr As HttpWebRequest = _
                CType(WebRequest.Create("http://thewebsite.com/thexmlfile.xml"), HttpWebRequest)
        Dim wrp As HttpWebResponse = CType(wr.GetResponse, HttpWebResponse)
        Dim s As Stream = wrp.GetResponseStream

Open in new window

0
Comment
Question by:ALawrence007
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 23

Accepted Solution

by:
Snarf0001 earned 500 total points
ID: 20289974
Use streamreader and streamwriter objects
I use c# instead of VB, so forgive me if syntax is off a bit, but something like the following:

Dim wr as HttpWebRequest = HttpWebRequest.Create("http://thewebsite.com/thexmlfile.xml")
Dim wrp as HttpWebResponse = wr.GetResponse

Dim sr as StreamReader = new StreamReader(wrp.GetResponseStream)
Dim sw as StreamWriter = new StreamWriter("thelocalxmlfile.xml", false)
sw.Write(sr.ReadToEnd)
sr.Close
sw.Close
0
 

Author Comment

by:ALawrence007
ID: 20291308
Thanks Snarf0001!
Worked like a charm!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question