2016-06-13 31 views
1

我想用gammu發送帶有地址和信息的短信,但是我的gammu參數有問題。如果我只啓動它運行的程序(string cmd1 = "c:\\G133\\bin\\gammu.exe ";)。添加參數後,它給出了這樣的失敗:用參數啓動gammu

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" 

回答

1

你需要調用Start方法,它有兩個參數,過載:

  • 第一個:要運行的文件;
  • 第二個:參數

它會看起來像:

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

System.Diagnostics.Process.Start(app, prms); 
+0

故障消失感謝你,但短信仍然沒有發。一些命令窗口出現後,它關閉很快我無法讀取:(你有任何想法趕上它? – Zoltan

+0

可執行文件c#文件必須在gammu config目錄....比它的工作感謝所有 – Zoltan

+0

不客氣,很高興提供幫助。 – MaKCbIMKo

1

你應該拆分應用程序和參數:

Process.Start(@"C:\G133\bin\gammu.exe", "--sendsms TEXT +12121234567 -text \"Hello\"");