1

我想gammu用来发送带有地址和消息的短信,但是我的gammu参数有问题。如果我只启动它运行的程序(string cmd1 = "c:\\G133\\bin\\gammu.exe ";)。添加参数后,它会失败:

System.ComponentModel.Win32Exception'发生在 System.dll
附加信息:系统找不到指定的文件:

代码:

string[] sms = File.ReadAllLines(@"C:\\temp\\test.txt");

string address = sms[0];
string message = sms[1];

string cmd1 = @"C:\G133\bin\gammu.exe --sendsms TEXT" + " " +  
    "\"" + address + "\" -text " + " " + "\"" + message + "\"";

System.Diagnostics.Process.Start(cmd1);

谁能帮我?提前致谢。

输出看起来不错:

Console.WriteLine(cmd1); - result

C:\G133\bin\gammu.exe --sendsms TEXT +12121234567 -text "Hello"
4

2 回答 2

1

您应该拆分应用程序和参数:

Process.Start(@"C:\G133\bin\gammu.exe", "--sendsms TEXT +12121234567 -text \"Hello\"");
于 2016-06-13T11:57:42.433 回答
1

您需要调用Start带有两个参数的方法的重载:

  • 第一个:要运行的文件;
  • 第二个:参数

它看起来像:

string app = @"path\to\your\target\app";
string prms = "your parameters";

System.Diagnostics.Process.Start(app, prms);
于 2016-06-13T11:59:04.713 回答