您好,我想在我的 XAML、WPF 应用程序中使用的一个单独类中获取应用程序路径。 在 Animals.cs 中,
string aPath2 = Application.StartupPath;
MessageBox.Show(path);
显示错误 错误 CS0117:“System.Windows.Application”不包含“StartupPath”的定义
我必须将数据提供给 treeview,我会从应用程序路径中的文件中获取所有详细信息。
最佳答案
使用AppDomain.CurrentDomain.BaseDirectory
StartupPath 仅适用于 Windows 窗体
关于c# - 通用类 (.CS) 中的应用程序路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2666442/