How to get Current Project Directory path using C#

后端 未结 9 780
旧巷少年郎
旧巷少年郎 2020-12-31 08:19

okay, here is the question. I have two projects one is C# Console and other is Class library. I am accessing/calling Class library method from the console app. There is a fo

9条回答
  •  伪装坚强ぢ
    2020-12-31 08:39

    If you loading the class library from another assembly.

    string Path = System.Reflection.Assembly.GetAssembly(typeof({LibraryClassName})).Location;
    
    string PathToClassLibPro = Path.GetDirectoryName( Path);
    

    Replace {LibraryClassName} with the class name of your library.

提交回复
热议问题