开发者

WebClient.DownloadFile Garbles Paths in Debug Mode

开发者 https://www.devze.com 2023-01-06 21:16 出处:网络
This 开发者_StackOverflow中文版is a really strange issue.When using WebClient.DownloadFile in Debug configuration, it appears as if it combines the source and destination paths and tries to do... some

This 开发者_StackOverflow中文版is a really strange issue. When using WebClient.DownloadFile in Debug configuration, it appears as if it combines the source and destination paths and tries to do... something. The destination file does get created (but it's empty). The problem dissaperes if I simply switch to Release configuration. Additionally, this used to work just fine, I can't determine what caused this strange behavior.

I'd say it might have something to do with path length but "Debug" < "Release" and that is the only difference between the two destinations when I switch configurations. Both are roughly 150 characters long.

Code:

client.DownloadFile(@"127.0.0.1/website/images/subscriber/test.png",
                                    @"C:\Users\{snip}\bin\Debug\Image Cache\3ea9858bb9e61bc36128bfe24dce35a4.png");

Exception:

Could not find a part of the path 'C:\Users\{snip}\bin\Debug\127.0.0.1\website\images\subscriber\test.png'.

The file is being served up by a WAMP environment, not IIS.


My guess is that since you're missing a scheme, it's assuming it's a local file.

Try making the first param into something like this instead: "http://127.0.0.1/website/images/subscriber/test.png"

0

精彩评论

暂无评论...
验证码 换一张
取 消