[英]How to run windows form's from Console?
I am new in Windows form application. 我是Windows窗体应用程序的新手。 I have created a Windows form.
我创建了一个Windows窗体。 the entry point of my solution is as per the below
我的解决方案的入口点如下
static void Main(string[] args)
{
Boolean bConsole = false;
for (int nArg = 0; nArg < args.Length; nArg++)
{
if (args[nArg].Equals("-Console", StringComparison.OrdinalIgnoreCase))
{
bConsole = true;
}
}
if (bConsole)
{
Form_Main form = new Form_Main();
form.Form_Main_Console();
}
else
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form_Main());
}
}
The application is working fine for windows form. 该应用程序适用于Windows窗体。 How can I run it from console ?
如何从控制台运行它? Can anyone help me regarding that?
有人可以帮我吗?
Compile your application to a binary (let's say MyApp.exe). 将您的应用程序编译为二进制文件(假设为MyApp.exe)。
Now in cmd.exe browse to the same directory (cd /path/to/exe) and type "MyApp.exe cmd1 cmd2". 现在,在cmd.exe中浏览到同一目录(cd / path / to / exe),然后键入“ MyApp.exe cmd1 cmd2”。
cmd1 and cmd2 appear as strings in the "string[] args" parameter to your Main function. cmd1和cmd2在您的Main函数的“ string [] args”参数中显示为字符串。 Do with them however you so please.
但是请与他们一起这样做。
Eg: 例如:
cd %ProgramFiles%/Path/To/App
MyApp -Console whatever
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.