For my apps, I store some configuration file in xml along with the assembly(exe), and something other temporary files for proccessing purpose.
I found some quirk w
System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location))
A tad shorter:
AppDomain.Current.BaseDirectory
Do you want the actual working directory, or the directory containing the assembly? It's not entirely clear.
There's Environment.CurrentDirectory if you want the working directory, or Path.GetDirectoryName(typeof(Foo).Assembly.ManifestModule.FullyQualifiedName)
to find the location of an assembly (or at least its manifest module, which will be the same thing in almost all cases).
I'd try something like this from the following link:
string path;
path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase );
MessageBox.Show( path );
Try the implementation below. The CodeBase property is the most reliable way to get the location, and then the rest of the code converts it into standard Windows format (instead of a URI).
static public string AssemblyLoadDirectory
{
get
{
string codeBase = Assembly.GetCallingAssembly().CodeBase;
UriBuilder uri = new UriBuilder(codeBase);
string path = Uri.UnescapeDataString(uri.Path);
return Path.GetDirectoryName(path);
}
}
How about
string currentAssemblyFile = System.Reflection.Assembly.GetExecutingAssembly().Location;
and then figure it out from there...