When I’m writing a utility that keeps some data I like to store it in my dropbox folder so it’s synchronised between all of my computers. This C# code will attempt to find where this folder is stores, or return null if it doesn’t seem to be there because either Dropbox isn’t installed or the internal details of how the location is stored has been changed again.
It checks in two locations because Dropbox changed where this was stored not so long ago and this code should work with both old and new installs.
var appDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
var dbPath = Path.Combine(appDataPath, "Dropbox\\host.db");