C# process.Start filename and passing arguments

后端 未结 1 1789
情书的邮戳
情书的邮戳 2021-01-25 08:31

I need to open the file test.mdb. The path must be fullpath built from whatever directory it is located in relative to the C# program exe

I need to pass the Arguments li

相关标签:
1条回答
  • 2021-01-25 09:35

    I don't think you need to worry about detecting the office version, just this should work for you:

            string filepath = '"' + Directory.GetCurrentDirectory() + "\\test.mdb" + '"';
            string acc_cmd_arg = "HELLO";
    
            using (System.Diagnostics.Process process = new System.Diagnostics.Process() )  {
                process.StartInfo.FileName = "msaccess.exe";
                process.StartInfo.Arguments = filepath + " /cmd " + acc_cmd_arg;
                process.Start(); 
            }
    
    0 讨论(0)
提交回复
热议问题