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
Solved

Save HttpWebResponse XML file to Local Computer

Posted on 2007-11-15
2
1,119 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
2 Comments
 
LVL 22

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Powershell File Sort 8 41
Very Large data in MYSQL 7 73
VB.Net. Reading xml value 6 29
Where does legacy ASP.NET initialize language? 2 22
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

856 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