Вопрос

Possible Duplicate:
.Net Process.Start default directory?

I have a C# application, mono to be specific. This application needs to launch another application on the users system. I know of Process.Start and how to use it, but theres something pecuilar about this instance which makes that not work correctly.

For some reason the program I am trying to launch via Process.Start needs to be called from the directory it resides in, otherwise it gives an error on opening.

What I mean by that is, if I open up a command prompt and type in: C:\appFolder\app.exe The application will then give me an error.

However if I open a prompt and go: cd c:\appFolder app.exe

It then launches just fine.

The problem I am having with process.start is it tries to open the application without first doing what is the equivalent of 'cd c:\appFolder', and so the application gives an error on opening.

So how can I do make Process.Start do what would be the equivalent of first navigating to the apps folder 'cd c:\appFolder' and then calling app.exe?

BTW, I have solved this problem by putting cd C:\appFolder app.exe

into a .bat file, and have Process.Start open the .bat file, which works just fine. But I am curious to know if there is a way to cut out the .bat file.

Нет правильного решения

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top