我试图断开/连接我的调制解调器适配器,命名为“конект”,但它不起作用,因为适配器的名称包含俄语字母。如何强制它工作?请帮忙。如果包含俄文字母,命令不执行?
连接(“конект”,“”,“”,true);
public static void Connect(string adapter, string login, string pass, bool discon)
{
string cmd = "";
if (discon)
{
cmd = "rasdial " + '"' + adapter + '"' + @" /disconnect";
}
else
{
cmd = "rasdial " + '"' + adapter + '"' + " " + login + " " + pass;
}
Cmd(cmd);
}
public static void Cmd(string URL)
{
ProcessStartInfo startInfo = new ProcessStartInfo("CMD.exe");
Process p = new Process();
startInfo.RedirectStandardInput = true;
startInfo.UseShellExecute = false;
startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardError = true;
startInfo.CreateNoWindow = true;
p = Process.Start(startInfo);
p.StandardInput.WriteLine(URL);
p.StandardInput.WriteLine(@"EXIT");
p.WaitForExit();
p.Close();
}
[我知道,只需要重命名以英文字母和代码将工作适配器,但我想知道如何迫使它与俄文字母工作]
“不起作用”是什么意思?你是否遇到异常,或者它是否意味着它不会断开连接? –
当你用俄语字母尝试时会发生什么? –
没有例外。什么都没发生。 – Halabella