开发者

VB.NET Folder location

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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜