I have winform, and its full path is C: \ test.exe
How do I get the full winform path at runtime? For example, a user may move winform to other places. Thanks.
Since you use WinForms, there are two simple properties in the Application class:
Application
Application.StartupPath
Application.ExecutablePath
This will give you the file name: System.Reflection.Assembly.GetExecutingAssembly (). ManifestModule.Name
For the folder name, try: System.Reflection.Assembly.GetExecutingAssembly (). Location (not sure ... on my head)
You can call Assembly.GetEntryAssembly () .CodeBase (or location) from a Windows-Form application (but not from ASP.NET applications).
This information is part of the My namespace. The directory path can be found through My.Application.Info.DirectoryPath
You can also use
Environment.CurrentDirectory It will provide you with the full path to the working directory.
Environment.CurrentDirectory