[英]How to get path of project using custom user control in c#
我在WinForms中創建了自定義用戶控件,現在我想將自定義用戶控件拖放到新項目的窗體中時獲得項目的路徑。
示例: string path = UserControl1.ProjectPath;
。
最好的方法是什么?
您可以使用System.Reflection
和程序集的CodeBase
var path = Path.GetDirectoryName(typeof(UserControl1).Assembly.CodeBase);
這將為您提供包含DLL的文件夾。 它可能在您的項目中也可能不在。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.