如何在C#中使用相对路径 [英] How to use relative Path in C#

查看:666
本文介绍了如何在C#中使用相对路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友
我正在创建一个exe文件,因为我正在运行一个msi文件.为此,我将该msi文件添加到了项目中,现在当我通过.net enviorement运行此应用程序时,其运行和msi文件也为runnig,但是当我复制此exe文件时文件到其他地方,然后显示找不到该路径.

并使用以下给出的相对路径从exe运行我的msi文件:

Hello Friends
I am Creating a exe in that I am running one msi file.For that I added that msi file to project and now When I am running this application thru .net enviorement then its running and msi file also runnig but when I copied my this exe file to some other place then its showing that path not found.

And to run my msi file from exe I m using this relative path given below:

installerFilePath = @"../../sss1.msi";
     System.Diagnostics.Process installerProcess;
     installerProcess = System.Diagnostics.Process.Start(installerFilePath , "/q");



在此先感谢.
问候
Yogesh



Thanks In Advance.
Regards
Yogesh

推荐答案

是的,如果移动exe,则相对路径将改变.相对于使用它的exe的工作目录,这就是相对路径.
Yes, if you move your exe, the relative path will change. That''s what a relative path MEANS, relative to the working directory of the exe that uses it.


感谢Christian
很好.如果我将exe复制到其他地方,该问题的解决方案是什么.我是否也需要在此复制我的msi文件或任何其他解决方案?

问候
Yogesh
Thanks Christian
THats fine.So whats the solution to this problem If I copy my exe to some other place.Do I need to copy my msi file there too or any other solution?

Regards
Yogesh


这篇关于如何在C#中使用相对路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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