A rather simple question; how to find the path of the local directory in which my exe is placed? As-in I have an .exe and in the program I have to create a txt file in the directory where the exe is!
[language - C#]
So, if the exe is in C:/Temp and is started from there; my txt should be created in C:/Temp
If the user wishes to move the exe to D:/Temp and runs from there; I should be able to create the txt file in D:/Temp
I tried the Directory.GetCurrentDirectory() but that returns the directory of the execution of the program!
A path is a slash-separated list of directory names followed by either a directory name or a file name. A directory is the same as a folder.
A local path is the path to a folder or file on your local computer (e.g. C:\Program Files\Sitebulb). A UNC path is the path to a folder or file on a network and contains the server name in the path (e.g. \\server01\sitebulb\path).
To determine the exact location of your current directory within the file system, go to a shell prompt and type the command pwd. This tells you that you are in the user sam's directory, which is in the /home directory. The command pwd stands for print working directory.
Assembly.GetExecutingAssembly().Location
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With