需要有关指定文件路径的帮助 [英] need help regarding specifing the path of a file

查看:71
本文介绍了需要有关指定文件路径的帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好



以下是我的代码



hi all

below is my code

System.Diagnostics.Process.Start("C:\Users\501013\Videos\WpfApplication1\WpfApplication1\assemblies\FullHardWareInfo.exe")





现在如果我在其他系统中运行该文件给出路径错误..请告诉我如何设置路径..



谢谢



now if i run the file in other system its giving path error..please tell me how to set the path..

Thank you

推荐答案

你确定 C:\ Users \501013 \ ... 存在于其他电脑上吗?



对于WinForms,您可以使用:

Are you sure that C:\Users\501013\... exists on other computer?

For WinForms you can use:
Application.StartupPath();



但是WPF没有包含等效方法,因此,你需要使用类似的东西:


but WPF doesn''t contain equivalent method, so, you need to use something like that:

Dim appStartPath AS String = AppDomain.CurrentDomain.BaseDirectory;
'or
'Dim appStartPath AS String = System.IO.Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName)





更改代码取决于您的需求,然后使用:



Change the code depends on your needs, then use:

System.Diagnostics.Process.Start(appStartPath)





;)



;)


这篇关于需要有关指定文件路径的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆