在这里需要帮助,我经历了这个错误,即使我搜索了解决方案仍然不能帮助我..
我想使用HTTP协议来downloadFile文件,但使用不同的端口,这意味着不使用端口80,而是使用其他端口,如5151。代码在C#中运行良好,编译时没有任何错误。在调试期间,它显示无法找到路径/URL,但路径/URL在我的浏览器中工作正常,端口为5151 (http://localhost:5151,工作很好)。
你知道怎么做吗?
下面是代码,有没有遗漏的地方我应该补充一下?
client = new WebClient();
try
{
client.DownloadFile(@""+httpAddr + ":5151/factionusers.log", "factionusers.log");
}
catch
{
client.DownloadFile(@""+httpAddr2 + ":5151/factionusers.log", "factionusers.log");
}发布于 2012-12-31 09:47:18
也许您可以在httpAddr变量中添加一个"/“。
static void Main()
{
string httpAddr = "http://192.168.56.101";
var client = new WebClient();
try
{
client.DownloadFile(@"" + httpAddr + ":5151/readme.txt", "readme.txt");
}
catch
{
client.DownloadFile(@"" + httpAddr + ":5151/readme.txt", "readme.txt");
}
}在我的电脑里。一切都很顺利。
https://stackoverflow.com/questions/14096555
复制相似问题