Download a file from internet

From WxWiki
Jump to: navigation, search

Here is a small snippet to retrieve a file from network

wxURL url(wxT("http://www.example.com/file.txt"));
if(url.GetError()==wxURL_NOERR)
{
    wxString htmldata;
    wxInputStream *in = url.GetInputStream();

    if(in && in->IsOk())
    {
        wxStringOutputStream html_stream(&htmldata);
        in->Read(html_stream);
        wxLogMessage(htmldata);
    }
    delete in;
}

Code author : doublemax Taken from http://wxforum.shadonet.com/viewtopic.php?p=75852#75852