简体   繁体   中英

VB.NET Folder location

My program uses some external programs that i included in the Files 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")

请在位置路径之前添加application.path。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM