[Solved] Running Program from USB drive [closed]


You can get the executing assembly path.

string path = (new System.Uri(Assembly.GetExecutingAssembly().CodeBase)).AbsolutePath;

From there, you can obtain the drive letter (path root):

string drive = Path.GetPathRoot(path);

If your file is in the same directory as the executable, you can get the file path like this:

string directory = Path.GetDirectoryName((new System.Uri(Assembly.GetExecutingAssembly().CodeBase)).AbsolutePath);
string databaseFile = Path.Combine(directory, "filename.dbf");

11

solved Running Program from USB drive [closed]