我有一个接受ARGS我的Windows应用程序,我为了建立窗口行为传递ARGS(参数)到窗口申请表格
问题,请使用这是我需要通过文本中的一些这个论点但我的应用程序是看着它作为多个指定参数时,那么,这样的:
"http://www.google.com/" contact 450 300 false "Contact Info" true "Stay Visible" true
实际上有参数,而不是在,我期待。
什么手段来得到“联系信息”和“看得到”因为只有一个参数传递?
我有一个接受ARGS我的Windows应用程序,我为了建立窗口行为传递ARGS(参数)到窗口申请表格
问题,请使用这是我需要通过文本中的一些这个论点但我的应用程序是看着它作为多个指定参数时,那么,这样的:
"http://www.google.com/" contact 450 300 false "Contact Info" true "Stay Visible" true
实际上有参数,而不是在,我期待。
什么手段来得到“联系信息”和“看得到”因为只有一个参数传递?
你是直接从命令行运行它吗?如果是这样,我希望能够正常工作。 (我假设你正在使用的参数从Main方法,方式)
举例来说,这里是一个小的测试应用程序:
using System;
class Test
{
static void Main(string[] args)
{
foreach (string arg in args)
{
Console.WriteLine(arg);
}
}
}
执行:
>test.exe first "second arg" third
first
second arg
third
这是一个控制台应用程序,但是就传递给Main方法的内容而言,它与WinForms之间没有区别。
MSDN says,它应该按照你提到的方式工作。
class CommandLine
{
static void Main(string[] args)
{
// The Length property provides the number of array elements
System.Console.WriteLine("parameter count = {0}", args.Length);
for (int i = 0; i < args.Length; i++)
{
System.Console.WriteLine("Arg[{0}] = [{1}]", i, args[i]);
}
}
}
你是如何执行你的应用程序?
如果你从你可能已经忘记了正确格式化参数字符串另一个应用程序执行:
String arguments = "First \"Sec ond\" Third Fourth \"Fi fth\""
将有五个参数,而
String arguments = "First Sec ond Third Fourth Fi fth"
将有七个。
如果参数在快捷方式目标属性,则同样适用:
"C:\My Path\MyApplication.exe" "Argument 1" Argument2 Argument3 "Argument 4"
,而不是
"C:\My Path\MyApplication.exe" Argument 1 Argument2 Argument3 Argument 4
约翰那是欺骗......让在第一:-)但只给一半回答第一次:-) – 2009-01-21 11:14:36