My program uses some external programs that i included in the 开发者_StackOverflowFiles folder.
In my code im reffering to Files/external_program.exe Windows Vista & Windows 7 knows how to handle this and starts the program on the same location as my program in the Files folder.
But Xp doesnt know where it is, and Windows XP will think im reffering to the C:\Files folder. So im getting an error and the app crashes.
How can i fix this? so windows xp will know that i'm reffering to the Files folder on the same location as my program.
Check out application.startuppath
http://msdn.microsoft.com/en-us/library/system.windows.forms.application.startuppath.aspx
dim progdir as string=application.startuppath & "\files\externalexe.exe"
The current working directory can be accessed via Environment.CurrentDirectory
. I'd also advice to always use the Path.Combine
function to join paths, because it already deals with any edge cases you might encounter.
Path.Combine(Environment.CurrentDirectory, "Files\external_program.exe")
Please add application.path before the path of the location.
精彩评论