문제

I have a file that is dynamically created (ie I request it via a handler http://mysite.com/images/1849?encoding=UTF-8&b=100") It creates the image based on what attributes you pass in. I am trying to figure out how to use WebClient.DownloadFile to grab this file but cannot get it to work has anyone done this before? The error does not tell me anything "System.Net.WebException: An exception occurred during a WebClient request."

  WebClient Client = new WebClient();
  Client.DownloadFile("http://mysite.com/images22?encoding=UTF-8&b=100", @"c:\myfile.jpeg");
도움이 되었습니까?

해결책

Can't comment, need rep...

Have you tried wrapping the DownloadFile in a Try / Catch block and then displaying the error details? Specifically, if it's a HTTP error, or some other system error?

다른 팁

The second string parameter is a local file to download to, such as C:\image.bmp.

You could instead use DownloadData if you want a byte array to work with instead.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top