Search code examples
vb.netgoogle-drive-apionedrive

How do I find the OneDrive (SkyDrive) and GoogleDrive folders without the API?


Thanks to this article,

How do I programmatically locate my Dropbox folder using C#?

I can programmtically find the Dropbox folder. Now, without installing and using various APIs, how can I do the same for GoogleDrive and MS SkyDrive?

Vb.Net or C# solutions are OK...


Solution

  • I found part of the answer here...

    How do I programmatically locate my Google Drive folder using C#?

    Here is my code for three of the main Webfolder services

    Dim StoreFolder As String = ""
    ' Dropbox
    Dim dbPath As String = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Dropbox\\host.db")
    Dim lines() As String = System.IO.File.ReadAllLines(dbPath)
    Dim dbBase64Text As Byte() = Convert.FromBase64String(lines(1))
    StoreFolder = System.Text.ASCIIEncoding.ASCII.GetString(dbBase64Text)
    
    ' SkyDrive
    StoreFolder = My.Computer.Registry.GetValue("HKEY_CURRENT_USER\Software\Microsoft\SkyDrive", "UserFolder", Nothing)
    
    ' Google Drive
    Dim dbPath As String = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Google\\Drive\\sync_config.db")
    File.Copy(dbPath, "temp.db", True)
    StoreFolder = File.ReadAllText("temp.db", System.Text.Encoding.ASCII)
    StoreFolder = StoreFolder.Substring(StoreFolder.IndexOf("local_sync_root_pathvalue") + 29)
    StoreFolder = StoreFolder.Substring(0, StoreFolder.IndexOf(Char.ConvertFromUtf32(24)))