我浏览了一下,找不到任何可以解决这个问题的东西;
我正在使用 ForceBind 强制浏览器使用 wi-fi 连接而不是以太网连接。为了使用 ForceBind 启动浏览器,我使用了一个快捷方式,其目标字段是:
C:\Windows\System32\ForceBindIP.exe 192.168.2.91 "C:\Program Files\Mozilla Firefox 3.6\firefox.exe" (我基本上是在启动 ForceBind 程序并告诉它启动浏览器)
这里的主要问题是每次我连接到无线网络时IP地址都会明显改变(并且由于与这里无关的原因,我无法设置固定地址来尝试从路由器请求),所以我写了下面的代码来获取当前无线适配器的地址:
static void Main(string[] args)
{
try
{
//Variable declaration
string adapterName = "";
string adapterIPAddress = "";
int num = 0; //assisting var
NetworkInterface[] interfaceList = NetworkInterface.GetAllNetworkInterfaces();
for (int i = 0; i < interfaceList.Length; i++)
{
if ((interfaceList[i].NetworkInterfaceType == NetworkInterfaceType.Wireless80211) && (interfaceList[i].OperationalStatus == OperationalStatus.Up))
{
adapterName = interfaceList[i].Name;
var ipProperties = interfaceList[i].GetIPProperties();
foreach (var ip in ipProperties.UnicastAddresses)
{
if (ip.Address.AddressFamily == AddressFamily.InterNetwork)
{
adapterIPAddress = ip.Address.ToString();
}
}
num = i;
break;
}
}
Console.WriteLine("Adapter name: " + adapterName);
Console.WriteLine("Adapter type: " + interfaceList[num].NetworkInterfaceType);
Console.WriteLine("Address: " + adapterIPAddress);
Console.WriteLine("");
//Create a string that represents the path with the appropriate IP Address
///< C:\Windows\System32\ForceBindIP.exe xxx.xxx.xxx.xxx "C:\Program Files\Mozilla Firefox 3.6\firefox.exe" >
string newPath = "C:/Windows/System32/ForceBindIP.exe " + adapterIPAddress + " \"C:/Program Files/Mozilla Firefox 3.6/firefox.exe\"";
Console.WriteLine("New path: ");
Console.WriteLine(newPath);
Console.WriteLine("Press Enter to launch...");
Console.ReadLine();
System.IO.File.Open(newPath, FileMode.Open);
}
catch (Exception ex)
{
Console.WriteLine("Oh no! Something went wrong! Bummer.", ex.Message);
}
}
问题是,在尝试启动 (System.IO.Open...) 时,我收到一个异常,说路径具有非法字符。所以一个。什么是非法字符,如何启动文件,或者 b. 如果我的计算机上有一个现有的快捷方式,我如何让该程序编辑其目标(仅更改 IP 地址)并启动它?