Find the location of my application's executable in WPF (C# or vb.net)?

前端 未结 7 1344
借酒劲吻你
借酒劲吻你 2020-12-08 04:02

How can I find the location of my application\'s executable in WPF (C# or VB.Net)?

I\'ve used this code with windows forms:

Application.ExecutablePat         


        
相关标签:
7条回答
  • 2020-12-08 04:42

    This is what I use. It works even in debugger.

    using System.IO;
    using System.Diagnostics;
    
    public static string GetMyBinDirectory()
    {
        return Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName);
    }
    

    It uses some powerfull classes, like Process and ProcessModule

    0 讨论(0)
提交回复
热议问题