zoukankan      html  css  js  c++  java
  • C#调用exe


    namespace WpfTest2
    {
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
    public MainWindow()
    {
    InitializeComponent();
    }

    private void Button_Click(object sender, RoutedEventArgs e)
    {
    //string debugPath = System.Environment.CurrentDirectory; //此c#项目的debug文件夹路径
    string pyexePath = @"C:UsersuserDesktop estdistmain.exe";
    //python文件所在路径,一般不使用绝对路径,此处仅作为例子,建议转移到debug文件夹下

    Process p = new Process();
    p.StartInfo.FileName = pyexePath;//需要执行的文件路径
    p.StartInfo.UseShellExecute = false; //必需
    p.StartInfo.RedirectStandardOutput = true;//输出参数设定
    p.StartInfo.RedirectStandardInput = true;//传入参数设定
    p.StartInfo.CreateNoWindow = true;
    p.StartInfo.Arguments = "2 3";//参数以空格分隔,如果某个参数为空,可以传入””
    p.Start();
    string output = p.StandardOutput.ReadToEnd();
    p.WaitForExit();//关键,等待外部程序退出后才能往下执行}
    Console.Write(output);//输出
    p.Close();
    }
    }

    ————————————————
    版权声明:本文为CSDN博主「武林大皮虾」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
    原文链接:https://blog.csdn.net/qq_42063091/article/details/82418630

    365个夜晚,我希望做到两天更一篇博客。加油,小白!
  • 相关阅读:
    黑产上演《三体》剧情:蠕虫病毒入侵手机群发“钓鱼”短信
    安天AVL联合小米MIUI首擒顽固病毒“不死鸟”
    阿里云存储OSS服务端签名客户端直传
    mariadb 安装配置
    NPOI 打印设置
    windows2008 r2 网络负载均衡搭建
    SqlServer数据库技巧
    达梦数据库备份还原
    ASP.NET CORE Docker发布记录
    DataReader转换
  • 原文地址:https://www.cnblogs.com/qq2806933146xiaobai/p/13259855.html
Copyright © 2011-2022 走看看