0

I tried this:

String solutionName = Path.GetFileName(Process.GetCurrentProcess().MainModule.FileName);

but i get only the current project name.

  • 2
    A solution is simply a container for projects. It doesn't really mean anything in the context of a running application. If you can better explain why you need the solution name then we might be able help. – Dan Wilson Jul 31 '18 at 13:56
  • AppDomains and assemblies loaded into the AppDomain have location, like: `Path.Combine(AppDomain.CurrentDomain.BaseDirectory` or `Assembly.GetExecutingAssembly().Location` – ZorgoZ Jul 31 '18 at 14:01
  • "but i get only the current project name" And that´s all you should care for. In fact you can even have assemblies that don´t have any solution they "live" in, as they have been compiled by someone else who then copied those assemblies to whatever directory. – MakePeaceGreatAgain Jul 31 '18 at 14:01
  • This question might already have been answered here: https://stackoverflow.com/questions/2336818/how-do-you-get-the-current-solution-directory-from-a-vspackage – Bouke Jul 31 '18 at 14:02
  • Under what context do you call this function? If you are wring a VS addin, then you should use VS API to query the current solution, not the code snippet above. – Lex Li Jul 31 '18 at 15:28
  • For my project structure this worked for me: var SolutionFullPath = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.FullName; var tempStrings = SolutionFullPath.Split('\\'); var solutionName = tempStrings[2]; – Kristijan Apostolov Aug 01 '18 at 09:01
  • Does this answer your question? [How to get the current solution name from a Visual Studio Package project?](https://stackoverflow.com/questions/44699177/how-to-get-the-current-solution-name-from-a-visual-studio-package-project) – Tom Aug 25 '21 at 13:24

0 Answers0