如何在Windows窗体应用程序中获取应用程序物理路径

本文关键字:应用程序 获取 路径 Windows 窗体 | 更新日期: 2023-09-27 17:53:12

如何在Windows窗体中获得应用程序路径,我使用下面的代码,但它说像"方法未找到"

Application.ExecutablePath;
Application.StartupPath;

请告诉我是否遗漏了名称空间

thanks in advance

如何在Windows窗体应用程序中获取应用程序物理路径

这将返回应用程序的完整路径

System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)

你也可以这样做

          System.AppDomain.CurrentDomain.BaseDirectory

System.Windows.Forms.Application.StartupPath必须返回正在运行的可执行文件的路径

添加引用System.Windows.Forms并添加using section

using System.Windows.Forms;

一般Application.StartupPath()会给出应用程序的路径。还有r u缺少这个空间。System.Windows.Forms