0

I am working on linux environment and using Mono for development. i have a C# project in which i want to start another application/executable file. the code snippet is below:

string pathToDB = @"""/root/somefolder/anotherfolder/""";
                        Process process = new Process();
                        process.StartInfo.FileName = @"/root/somefolder/filename";
                        process.StartInfo.Arguments = @"""" + pathToDB + @"""" + "$" + contents + "$" + "documentTerms";
                        process.Start();    

i m passing three(3) arguments. 1st is a folder path, 2nd is some text data which i have represented by string contents , and 3rd one is some hard coded text. when i am running this program it gives me the following exception/error:

CreateProcess: Unfinished quote.

Exception: System.ComponentModel.Win32Exception: Invalid data
at System.Diagnostics.Process.Start_shell (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process) [0x00000] in <filename unknown>:0 
  at System.Diagnostics.Process.Start_common (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process) [0x00000] in <filename unknown>:0 
  at System.Diagnostics.Process.Start () [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.Diagnostics.Process:Start ()
  at XapianTest.SimpleIndex.ProcessFiles (System.String path) [0x000dc] in /root/Projects/XapianTest/XapianTest/SimpleIndex.cs:84 
  at XapianTest.SimpleIndex.ProcessFiles (System.String path) [0x0013d] in /root/Projects/XapianTest/XapianTest/SimpleIndex.cs:105 
  at XapianTest.SimpleIndex.ProcessFiles (System.String path) [0x0013d] in /root/Projects/XapianTest/XapianTest/SimpleIndex.cs:105 
  at XapianTest.SimpleIndex.Main (System.String[] argv) [0x00023] in /root/Projects/XapianTest/XapianTest/SimpleIndex.cs:51    

what am I doing wrong! please anyone help me...

Thanks in advance...

Muhammad Assad
  • 153
  • 1
  • 2
  • 6

1 Answers1

0

You need spaces between the arguments. Try this:

process.StartInfo.Arguments = @"""" + pathToDB + @""" ""$" + contents + @"$"" " + "documentTerms";
Rolf Bjarne Kvinge
  • 19,253
  • 2
  • 42
  • 86
  • thanks for advice. I have tried this but it gives me the following exception: `
    ` `xdg-open: unexpected argument '/root/xapian/quickstart/proverbs/' Try 'xdg-open --help' for more information.`
    – Muhammad Assad Jun 08 '12 at 08:02
  • /root/xapian/quickstart/proverbs/ is a directory, not an executable, that's the reason you're getting the error. – Rolf Bjarne Kvinge Jun 16 '12 at 00:54