在Windows应用程序中在运行时传递参数(命令行参数) [英] passing parameters at runtime(Command-line arguments) in windows application

查看:92
本文介绍了在Windows应用程序中在运行时传递参数(命令行参数)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友们,



我创建了一个基于窗口的应用程序来获取日期(从日期和到目的地)比较< b>数据库中的预订日期,结果将显示在 Crystal报表查看器上。



我创建了 exe文件并尝试在命令提示符上执行。但是我没有得到如何在Form_Load事件中获取这些参数(crystalReportViewer1_Load)。



任何人都可以帮忙解决这个问题....



我的命令行将是



c:> testRptExe''18 / 12/2012''''26 / 12/2012''

Dear Friends,

I have created a window based application to get dates(From Date and To Date) which compares the Booking Date from the database and result will be displayed on Crystal report Viewer.

I created an exe file of it and tried to execute on Command Prompt. But i am not getting how to get those parameter in Form_Load event(crystalReportViewer1_Load).

Can anyone please help to solve this....

My command-line will be

c:> testRptExe ''18/12/2012'' ''26/12/2012''

推荐答案

这根本没有意义。如果它是基于Windows的,那么就没有代码,它不是ASP.NET。如果它是一个Windows应用程序,参数将作为数组传入入口点。因此,您的问题是荒谬的
This makes no sense at all. If it''s windows based, there is no code behind and it''s not ASP.NET. If it''s a windows app, the parameters are passed in to the entry point as an array. And, your question therefore is nonsensical


您可以使用它从非主方法读取命令行参数
you can use this to read command line arguments from non-main method
foreach (string arg in Environment.GetCommandLineArgs())
{
    Console.WriteLine(arg);
}


这篇关于在Windows应用程序中在运行时传递参数(命令行参数)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆