In the case of Windows application, obtaining the current directory is simple; just use Application.StartupPath. For console applications, it is different. Multiple methods can be used and a few of them are listed below.
1. Use System.Environment.CurrentDirectory. It returns the directory, from which the current process started.
2. System.Reflection.Assembly.GetExecutingAssembly().Location returns the fully qualified name of the current executable. To extract the current directory name, call function
System.IO.Path.GetDirectoryName() with this value.
No comments:
Post a Comment