哪位大虾帮我解决C#调用DOS命令实现上网拨号的程序
有两个按钮 连接和断开,两个文本框填写拨号的登录账号密码,点击连接,调用DOS命令实现网络连接
点击断开,网络断开  
请哪位大虾帮我解决这个问题(要详细代码),谢谢!!!Process p = new Process();
            p.StartInfo.WorkingDirectory = "c:\\";
            p.StartInfo.FileName = @"cmd.exe";
            p.StartInfo.Arguments = "DOS 命令";
            p.StartInfo.UseShellExecute = false;
            p.StartInfo.RedirectStandardOutput = true;
            p.Start();
            string outpuut = p.StandardOutput.ReadToEnd();
            p.WaitForExit();这段代码 有错误,请哪位大虾改正!!

解决方案 »

  1.   

    我只实现过VPN 拨号程序。但是我想原理应该差不多的。
      

  2.   

    private string[] arrCommand = new string[2];
        private void FrmMain_Load(object sender, EventArgs e)
            {
                arrCommand[0] = "rasdial " + m_strADSLName + " /disconnect";
                arrCommand[1] = "rasdial " + m_strADSLName + " " + m_strADSLAcc + " " + m_strADSLPwd;
            }   private bool ReDial()
            {
                Process p = new Process();
                p.StartInfo.FileName = "cmd.exe";
                p.StartInfo.UseShellExecute = false;
                p.StartInfo.RedirectStandardInput = true;
                p.StartInfo.RedirectStandardOutput = true;
                p.StartInfo.RedirectStandardError = true;
                p.StartInfo.CreateNoWindow = true;
                string strOutput = null;
                try
                {
                    p.Start();
                    foreach (string item in arrCommand)
                    {
                        p.StandardInput.WriteLine(item);
                    }
                    p.StandardInput.WriteLine("exit");
                    strOutput = p.StandardOutput.ReadToEnd();
                    p.WaitForExit();            }
                catch (Exception e)
                {
                    strOutput = e.Message;
                    System.Threading.Thread.Sleep(1000);
                    return false;
                }
                finally
                {
                    if (p != null)
                        p.Close();
                }            if (strOutput.IndexOf("选择“错误信息”") >= 0)
                {
                    System.Threading.Thread.Sleep(1000);
                    return false;
                }
                return true;
            }
      

  3.   

    ADSL 拨号