c#下载字符串错误
本文关键字:错误 字符串 下载 | 更新日期: 2023-09-27 18:05:43
由于某些原因,当输入
public static Thread UDP = new Thread(UDPFlood);
public static string IP = GetIP();
public static string ownerURL = "{url}";
public static string GetIP()
{
ownerURL = ownerURL.Replace("{url}","http://www.test.com");
WebClient ipGrabber = new WebClient();
return ipGrabber.DownloadString(ownerURL + "/getIP.php");
}
抛出这个错误:
系统。的类型初始化项的传播者。FormMain抛出了一个异常。——> System.Net.WebException:找不到"C:'getIP.php"文件。——> System.Net.WebException:找不到"C:'getIP.php"文件。--->System.IO.FileNotFoundException:无法找到文件"C:'getIP.php".
基本上,当使用字符串+/getIP.php时,它在我的计算机上查找目录,而不是在web上。
类初始化器可能在初始化ownerURL
之前调用GetIP
。因此,ownerURL.Replace
调用没有做您想要的。