0

I am using WebClient.DownloadFileAsync to download files asynchronously to my machine. Occasionally, I end up with URLs which has a double quote on it.

For example, see this:
http://upload.wikimedia.org/wikipedia/en/d/d3/"Baby"_Palace_Hotel_1906.jpg.

DownloadFileAsync throws an "Illegal characters in path" exception when the file name contains double quotes. I am unable to decode the url either since DownloadFileAsync does not accept string as a parameter but only Uri.

What would be a good way to handle this situation?

Sreejith K.
  • 163
  • 1
  • 9

1 Answers1

0

Weird, the follownig works fine for me:

class Program
{
    static void Main()
    {
        using (var client = new WebClient())
        {
            client.DownloadFileCompleted += (sender, e) =>
            {
                Console.WriteLine("finished");
            };
            client.DownloadFileAsync(new Uri("http://upload.wikimedia.org/wikipedia/en/d/d3/\"Baby\"_Palace_Hotel_1906.jpg"), "test.jpg");
            Console.ReadLine();
        }
    }
}
Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
  • I figured it out. It was a mistake from my part. I have given the file name as the same as that from the url and so the path name was also containing a double quote. When I removed the quote, it worked. Thanks for trying. – Sreejith K. Sep 28 '11 at 08:10