VB.Net and C# methods to programmatically obtain the DropBox folder


I’ve tested this with both Windows 7 and Windows 8 (both 64-bit installations).

VB.Net

Public Function GetDropBoxFolder() As String
    Dim dbPath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Dropboxhost.db")

    Dim lines As String() = System.IO.File.ReadAllLines(dbPath)
    Dim dbBase64Text As Byte() = Convert.FromBase64String(lines(1))
    Dim folderPath As String = System.Text.ASCIIEncoding.ASCII.GetString(dbBase64Text)

    Return folderPath
End Function

C#

public string GetDropBoxFolder()
{
    var dbPath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Dropbox\host.db");
    string[] lines = System.IO.File.ReadAllLines(dbPath);
    byte[] dbBase64Text = Convert.FromBase64String(lines[1]);
    string folderPath = System.Text.ASCIIEncoding.ASCII.GetString(dbBase64Text);
    return folderPath;
}