开发者

Process.Start to run exe in same folder as application is

开发者 https://www.devze.com 2022-12-27 02:30 出处:网络
When I am running myProcess = Process.Start(\"something.exe\") and want to start it using button it doen not find the file - i need to execute it from the same folder where application is how can

When I am running

myProcess = Process.Start("something.exe")

and want to start it using button it doen not find the file - i need to execute it from the same folder where application is how can i do that? Thank you.

System could not fin开发者_运维技巧d this file - but it is there . in the same folder as application.

Using Visual Basic 2008 Express


When I add there this:

System.Diagnostics.Process.Start(System.IO.Path.Combine(My.Application.Info.DirectoryPath, "something.exe"))

It is working thanks for help - FIXED :-)


You should try something like

Process.Start(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "notepad.exe"))


When running from VS the folder with your application is the bin/Debug or bin/Release. The program should be there.

Another option is to add the path to the program extracted from Assembly.GetExecutingAssembly().GetName().CodeBase

0

精彩评论

暂无评论...
验证码 换一张
取 消