I want to get the path of my app like: \"\\\\ProgramFiles\\\\myApp\", I try to use the following code:
string path = System.Reflection.Assembly.GetExecuting
If its an exe as in your case use:
// Summary:
// Gets the path for the executable file that started the
// application, not including the executable name.
Application.StartupPath
path = System.IO.Path.GetDirectoryName( path );
More simple than the rest:
using System.IO;
using System.Reflection;
...
var path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)
Application.StartupPath
should do that for you.
Update: from you edit I see that you are running on Compact Framework. Then Application.StartupPath will not work. This is the construct that I usually use then:
private static string GetApplicationPath()
{
return System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
}
Path.GetFileNameWithoutExtension(path);
What about using a FileInfo object to extract the directory name?
In Vb.Net:
fi = New FileInfo(System.Reflection.Assembly.GetExecutingAssembly.Location)
path = fi.DirectoryName