-
[WPF] Get Solution DirectoryC#/WPF 2024. 10. 17. 15:45
public static class VisualStudioProvider { public static DirectoryInfo TryGetSolutionDirectoryInfo(string currentPath = null) { var directory = new DirectoryInfo( currentPath ?? Directory.GetCurrentDirectory()); while (directory != null && !directory.GetFiles("*.sln").Any()) { directory = directory.Parent; } return directory; } }
// get directory var directory = VisualStudioProvider.TryGetSolutionDirectoryInfo();
Getting path to the parent folder of the solution file using C#
I am a beginner in C#, and I have a folder from which I am reading a file. I want to read a file which is located at the parent folder of the solution file. How do I do this? string path = "";
stackoverflow.com
728x90'C# > WPF' 카테고리의 다른 글
[WPF] Build 시 폴더 OutDir 복사 (1) 2024.10.29 [WPF] PropertyGroup (4) 2024.10.28 [WPF] Call Async Method (0) 2024.10.04 [WPF] Sentry.io (0) 2024.08.22 [WPF] gRPC 프로젝트 생성 (0) 2024.08.01 댓글