First of all I know there are many questions that look like this one but I couldn't really get an answer for my problem.
So in general, I am running a program that needs to get a path to a solution of another visual studio project solution file and I only have the name of the file itself.
For example, my program is running in the background and there is a visual studio project currently being coded, I need to get the path to the solution of this project. The project wasn't compiled yet, it's a new project that was just created.
For example MyProject.sln
is the file and the directory I am looking for is C:\Users\MyUser\Documents\Visual Studio 2015\Projects\MyProject\MyProject.sln
. Of course the project can be anywhere on the computer, like a different drive, or not in the visual studio folder.
I tried using methods such as Path.GetDirectoryName(filename)
which returns an empty string, or Path.GetFullPath(path)
which returns a wrong path (the one of the program that searches for the path), or Directory.GetDirectories(path,searchPattern)
some with the SearchOptions, and then I get authorization errors for SearchOption.AllDirectories
on a lot of files.
I am really lost here, I hope someone can help!