如何获取当前可执行目录的路径 [英] How to get the path of current executable directory

查看:129
本文介绍了如何获取当前可执行目录的路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我使用VS安装程序开发了安装程序安装程序。我想在app.config中检索可执行文件目录路径。



假设



我的应用程序正在运行在C:\ program Files \ myApplication \ myapplication.exe



现在我想找到像c:\Program files\Myapplication <的可执行路径br />


我尝试了什么:



这里有c#代码的帮助我可以检索路径但是如何在app.config

hello i have develop a setup installer using VS installer. i want to retrieve the executable directory path in app.config.

Suppose

my application is running in C:\program files\myApplication\myapplication.exe

now i want to find the executable path like c:\Program files\Myapplication

What I have tried:

here with the help of c# code i can retrieve the path but how can i get it in app.config

推荐答案

中使用System获取它。例如

e.g.
using System.IO;
using System.Reflection;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            var path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);
        }
    }
}


这篇关于如何获取当前可执行目录的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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