Dropbox puts a file in the ApplicationData directory, called "host.db", which contains the Dropbox path in the second line. It's fairly simple to access that data, we just read the whole file (which is small), than we put the second line in a byte array converting it, and in the end we just put the string in a variable, converting in ASCII. It is simple and effective, doesn't require much time, and you can easily detect if an user has Dropbox installed or not by just checking the file existence in the default path. Here's the code:
string appData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); string dropboxPath = System.IO.Path.Combine(appData, "Dropbox\\host.db"); string[] lines = System.IO.File.ReadAllLines(dropboxPath); byte[] dropboxBase64 = Convert.FromBase64String(lines[1]); string folderPath = System.Text.ASCIIEncoding.ASCII.GetString(dropboxBase64);
On the Newer DropBox I have found out the it is not in the Roaming File it in the Local File path.... Here is the code that I have got working with DropBox.
ReplyDeletestring appData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
string dropboxPath = System.IO.Path.Combine(appData, "Dropbox\\host.db");
string[] lines = System.IO.File.ReadAllLines(dropboxPath);
byte[] dropboxBase64 = Convert.FromBase64String(lines[1]);
string folderPath = System.Text.ASCIIEncoding.ASCII.GetString(dropboxBase64);