简体   繁体   English

批量发送 arguments 到 exe 文件 C#

[英]batch send arguments to exe file C#

I'm wanting a batch file, send data to an exe file programmed in C#, and this data will be saved in variables in the program, is this possible?我想要一个批处理文件,将数据发送到C#中编程的exe文件,这些数据将保存在程序中的变量中,这可能吗? if yes how can i do that?如果是的话,我该怎么做?

You can pass parameters via the commandline as documented here :您可以通过命令行传递参数,如此所述:

using System;

class TestClass
{
    static void Main(string[] args)
    {
        // Display the number of command line arguments.
        Console.WriteLine(args.Length);
    }
}

An alternative would be to set environment variables and use their values within the program:另一种方法是设置环境变量并在程序中使用它们的值:

public static string? GetEnvironmentVariable (string variable);

Yes.是的。 The standard mechanisms are标准机制是

  1. The command line 命令行

  2. Environment Variables 环境变量

  3. Standard Input 标准输入

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM