0

I am unable to download images from an RSS Feed, where the URL doesn't contain a filename.

Example -

Image URL I would like to download (it works if you click on it in a browser, but in code it doesn't work):

http://www.deviantart.com/download/286471805/

Using the code below I get a "An exception occurred during a WebClient request." error. I have no idea why this isn't working.

Any ideas on how I can save these files?

    private void Start_Button_Click(object sender, EventArgs e)
    {
        WebClient MyDownloader = new WebClient();

            MyDownloader.DownloadFile(@"http://www.deviantart.com/download/286471805/", @"c:\test\");

    }

1 Answer 1

4

You have to specify a file name as the second argument, not the download directory:

using (var client = new WebClient())
{
    client.DownloadFile("http://www.deviantart.com/download/174633066/",
                        @"c:\test\file.png");
}                                     ↑
Sign up to request clarification or add additional context in comments.

3 Comments

The file name is not given in the RSS feed - which is actually the issue I am having (ie. RSS FEED: backend.deviantart.com/…). The RSS feed only contains the link I have with no filename. How can I get the filename?
Maybe you can use the id that is in the url. It's up to you which name do you want/need for that file.
It seems "the filename" you're referring to is the location to which your URL redirects. See: Getting the location from a WebClient on a HTTP 302 Redirect?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.