zoukankan      html  css  js  c++  java
  • c#调用外部程序

     private System.Timers.Timer m_timer;
       
        void Application_Start(object sender, EventArgs e)
        {
            m_timer = new System.Timers.Timer(1000);
            m_timer.Enabled = true;
            m_timer.Elapsed += new System.Timers.ElapsedEventHandler(m_timer_Elapsed);  //事件代理
            //开启时钟。
            m_timer.Start();

        }       

    //定时执行 事件

     private void m_timer_Elapsed(object sender, System.Timers.ElapsedEventArgs args)
        {

    string mypath = "cd " + HttpRuntime.AppDomainAppPath;
            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;
            p.Start();
           // p.StandardInput.WriteLine("c:");
            p.StandardInput.WriteLine(mypath);
            p.StandardInput.WriteLine("s.pl");
            p.StandardInput.WriteLine("md ok8");
            p.StandardInput.WriteLine("exit");
            string myreult = p.StandardOutput.ReadToEnd();
            p.Close();
            File.WriteAllText(@"C:\re.txt", myreult);

    }

  • 相关阅读:
    linux下tomcat内存溢出
    leetcode
    HDU 4810 Wall Painting (位操作-异或)
    详解Java中的访问控制修饰符(public, protected, default, private)
    mpvue开发微信小程序之时间+日期选择器
    多行文本溢出隐藏
    swift 多态函数方式
    swift 多态函数方式
    swift 多态函数方式
    swift 多态函数方式
  • 原文地址:https://www.cnblogs.com/a311300/p/1806420.html
Copyright © 2011-2022 走看看