-1

I'm actually making a little application that can find on any computer the list of the different cloud storage installed and i wonder how i can get the path to the Skydrive folder in C#.

I managed to get the path of dropbox and google drive with information stored in appdata/roaming folder but i don't manage to do the same thing with Skydrive.

For dropbox:

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

For google drive :

String dbFilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Google\\Drive\\sync_config.db");

            File.Copy(dbFilePath, "temp.db", true);
            String text = File.ReadAllText("temp.db", Encoding.ASCII);

            // The "29" refers to the end position of the keyword plus a few extra chars
            String trim = text.Substring(text.IndexOf("local_sync_root_pathvalue") + 29);

            // The "30" is the ASCII code for the record separator
            String drivePath = trim.Substring(0, trim.IndexOf(char.ConvertFromUtf32(30)));

If you want to get the path to the skydrive folder you need to use the Registery value at HKEY_CURRENT_USER\Software\Microsoft\SkyDrive, with the name UserFolder. Here is the code :

String SkyDriveFolder = Registry.GetValue("HKEY_CURRENT_USER\\Software\\Microsoft\\SkyDrive", "UserFolder",null).ToString();  
4

3 回答 3

3

如果您想获取 skydrive 文件夹的路径,您需要使用 HKEY_CURRENT_USER\Software\Microsoft\SkyDrive 中的 Registery 值,名称为 UserFolder。这是代码:

String SkyDriveFolder = Registry.GetValue("HKEY_CURRENT_USER\\Software\\Microsoft\\SkyDrive", "UserFolder",null).ToString();  
于 2013-05-24T12:22:46.890 回答
1

似乎在 Windows 7 中安装 SkyDrive 程序时,SkyDrive 路径可以在

HKEY_CURRENT_USER\Software\Microsoft\SkyDrive

但是,在 Windows 8 中,SkyDrive 是操作系统的一部分,因此路径存储在

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\SkyDrive

要更加跨平台兼容,只需检查两个注册表项。

于 2013-07-09T18:33:28.710 回答
0

如果您查看:

C:\Users\{username}\AppData\Local\Microsoft\SkyDrive\settings

您将看到一个 .ini 文件,类似于:

072d8533c42d12c1.ini- 其中包含:

library = 1 4 072d8533c42d12c1!173 121684168 "SkyDrive" Me personal "{path to skydrive folder}"

我不确定这是否是查找文件夹的万无一失的方法,使用风险自负!

于 2013-05-24T11:44:06.770 回答