我有一个winform,它的完整路径是C:\test.exe
如何在运行时获取winform完整路径?例如,用户可以将winform移动到其他地方。谢谢。
发布于 2011-08-18 07:01:05
当您使用WinForms时,在Application类上有两个简单的属性可供选择:
Application.StartupPath将为您提供应用程序started.Application.ExecutablePath将在其中为您提供应用程序的完整路径(包括文件名)的目录。发布于 2011-08-18 06:59:28
这将为您提供文件名: System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name
对于文件夹名称,请尝试: System.Reflection.Assembly.GetExecutingAssembly().Location (不确定...在我的头顶)
发布于 2011-08-18 07:00:22
可以从Windows窗体应用程序(但不能从ASP.NET应用程序)调用Assembly.GetEntryAssembly ().CodeBase (或Location)。
https://stackoverflow.com/questions/7100526
复制相似问题