Two questions about System.Diagnostics.Process.Start function

  • Thread starter Thread starter ginee lee via .NET 247
  • Start date Start date
G

ginee lee via .NET 247

(Type your message here)
hi all,
It seems that the arguments of System.Diagnostics.Process.Start()can only be the absolute path. The args can not be like".\abc\efg.exe" or "..\abc\efg.exe". While i use relative path,the function doesn't work. Any solution??

The other question is... i take a example fisrt!
System.Diagnostics.Process.Start("c:\\abc.exe", "hello.txt"); itworks fine. BUT if the second arg replace with "helloworld.exe", something wrong! the function looks likeSystem.Diagnostics.Process.Start("c:\\abc.exe", "helloworld.txt"); I think it is because the command will treat the"hello world.txt" as two args "hello" and "world.txt". Is thereother way to resolve this issue!??

Thanks
 
1. It is possible to use relative path. You might have to check your
current directory and verify if you're pointing to the right executable.

2. For arguments with spaces, you can use quotes. So, you can give,

Process.Start ("c:\\abc.exe", "\"hello world.txt\"");

-vJ

(Type your message here)
hi all,
It seems that the arguments of System.Diagnostics.Process.Start() can only
be the absolute path. The args can not be like ".\abc\efg.exe" or
"..\abc\efg.exe". While i use relative path, the function doesn't work. Any
solution??

The other question is... i take a example fisrt!
System.Diagnostics.Process.Start("c:\\abc.exe", "hello.txt"); it works fine.
BUT if the second arg replace with "hello world.exe", something wrong! the
function looks like System.Diagnostics.Process.Start("c:\\abc.exe", "hello
world.txt"); I think it is because the command will treat the "hello
world.txt" as two args "hello" and "world.txt". Is there other way to
resolve this issue!??

Thanks
 
Back
Top