[MonoDevelop] Best way to find the current directory
m.j.hutchinson at gmail.com
Wed Apr 7 09:56:42 EDT 2010
On Wed, Apr 7, 2010 at 9:34 AM, Steve Ricketts <velocedge at hotmail.com> wrote:
> I'm using the following to find the current directory and any command line
> foreach (string arg in Environment.GetCommandLineArgs())
> CommandLine = CommandLine + arg + " ";
> Is there a better way to get the current (executable) directory within C#?
The executable's directory: Path.GetDirectoryName
Working directory: Environment.CurrentDirectory
Directory of the assembly some type is in: Path.GetDirectoryName
(assuming: using System; using System.Reflection; using System.IO;)
Btw, your example is rather odd - why join the arguments? Also,
concatenating strings in a loop is generally a bad practice as it
causes lots of garbage. Use string.Join or a StringBuilder.
More information about the Monodevelop-list