I need to open a folder 3 levels down from where application executes (original example I had have some flaws):
// find the path where the executable resides
string dbPath = Application.StartupPath;
// constructing the connection string - double slashes
string connString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source="
+ dbPath + "\\..\\..\\..\\Magazines.accdb; User Id=admin; Password=";
But this will open:
C:\Documents and Settings\Server\Desktop\Lab 10\Lab 10\Lab 10\bin\Debug\..\..\..\Magazines.accdb
Original directory from where program starts:
C:\Documents and Settings\Server\Desktop\Lab 10\Lab 10\Lab 10\bin\Debug\
And I need it to be:
C:\Documents and Settings\Server\Desktop\Lab 10\Lab 10\Magazines.accdb
What is the proper was of doing this?
Use DirectoryInfo for evaluating the ‘..’
Also use
Path.Combinefor eased and more reliable combination.