C# 如何编辑快捷方式';它的目标是什么?
我仔细看了一遍,找不到任何确切的地址 我使用ForceBind强制浏览器使用wi-fi连接,而不是以太网连接。 为了使用ForceBind启动浏览器,我使用了一个快捷方式,其目标字段是: C:\Windows\System32\ForceBindIP.exe 192.168.2.91“C:\Program Files\Mozilla Firefox 3.6\Firefox.exe” (我基本上是启动ForceBind程序,并告诉它启动浏览器) 这里的主要问题是,每次我连接到无线网络时,IP地址都会发生明显的变化(由于与此无关的原因,我无法设置固定地址来尝试从路由器请求),因此我编写了以下代码来获取当前无线适配器的地址:C# 如何编辑快捷方式';它的目标是什么?,c#,target,shortcut,C#,Target,Shortcut,我仔细看了一遍,找不到任何确切的地址 我使用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);
}
}
static void Main(字符串[]args)
{
尝试
{
//变量声明
字符串适配器名称=”;
字符串适配器paddress=“”;
int num=0;//var
NetworkInterface[]interfaceList=NetworkInterface.GetAllNetworkInterfaces();
for(int i=0;i
字符串newPath=“C:/Windows/System32/ForceBindIP.exe”+adapterIPAddress+“\”C:/ProgramFiles/Mozilla Firefox 3.6/Firefox.exe\”;
Console.WriteLine(“新路径:”);
Console.WriteLine(newPath);
Console.WriteLine(“按Enter键启动…”);
Console.ReadLine();
System.IO.File.Open(newPath,FileMode.Open);
}
捕获(例外情况除外)
{
Console.WriteLine(“哦,不!出了点问题!糟糕透了。”,例如Message);
}
}
问题是,当尝试启动(System.IO.Open…)时,我得到一个异常,说路径有一个非法字符。所以a。什么是非法字符,如何启动文件,或b。如果我的计算机上存在快捷方式,如何让该程序编辑其目标(仅更改IP地址)并启动它?File.Open()没有任何意义。你是说Process.Start()吗?如果要修改.lnk文件,请在搜索框中键入“shelllinkobject”。