I’m in Visual Studio, making a Windows Forms application. I’m having some difficulties with the relative paths.
For example, connecting to a database, with an OleDbConnection, with a relative path of “\Databases\bla.mdb” works great while debugging from Visual Studio. However, if the executable path is somepath\Debug\app.exe, the database is actually in somepath\Databases\bla.mdb”
Where’s the setting that defines that “base path” that’s being used?
I checked for Application::CommonAppDataPath, ExecutablePath, StartupPath, UserAppDataPath and LocalUserAppDataPath, none returns “somepath”.
The final idea is that the Databases folder will be in the same folder as the executable, but if I hardcode that with ExecutablePath or something like that, it doesn’t work while debugging… And if I leave it as is, in my computer it works fine (debugging and deployed with the Databases folder in the same folder as the .exe) but I tried it in another laptop and it searches for the Databases folder somewhere inside My Documents.
I’d appreciate any advice, answers or orientation. My googling hasn’t been helpful so far
Meaning your debug directory layout is not the same as your deployment directory layout?
That’s not a good plan. Instead of trying to “re-base” the root directory of your application for relative paths in debug vs deployment, you should try and match the directory layout for both scenarios.