Suppose you deploy your app.config with this connectionstring
"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|yourFile.accdb;"
In a WinForms application the |DataDirectory|
shortcut represent your application working folder, but you can change at runtime where it points to using this code.
// appdomain setup information
AppDomain currentDomain = AppDomain.CurrentDomain;
//Create or update a value pair for the appdomain
currentDomain.SetData("DataDirectory", "Your user choosen path");
It eliminates the need to hard-code the full path which, has you have discovered, leads to several problems to resolve during install. Of course your setup should deliver your database in your user choosen path.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…