[英]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. 在我的代码中,它们对应于Files / external_program.exe,Windows Vista和Windows 7知道如何处理该问题,并在与我的文件文件夹中的程序相同的位置启动该程序。
But Xp doesnt know where it is, and Windows XP will think im reffering to the C:\\Files folder. 但是Xp不知道它在哪里,Windows XP会认为我是在引用C:\\ Files文件夹。 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.
因此,Windows XP会知道我引用了与程序位于相同位置的Files文件夹。
Check out application.startuppath 签出application.startuppath
http://msdn.microsoft.com/en-us/library/system.windows.forms.application.startuppath.aspx http://msdn.microsoft.com/zh-cn/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
. 可以通过
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
函数来连接路径,因为它已经处理了您可能遇到的任何边缘情况。
Path.Combine(Environment.CurrentDirectory, "Files\external_program.exe")
请在位置路径之前添加application.path。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.