更新时间:2023-02-10 22:53:16
更新的解决方案
现在的Dropbox作为提供这里所说的info.json文件: HTTPS://www.dropbox。 COM / EN /帮助/ 4584
Dropbox now provides an info.json file as stated here: https://www.dropbox.com/en/help/4584
如果你不想处理解析JSON,你可以简单地用以下解决方案:
If you don't want to deal with parsing the JSON, you can simply use the following solution:
var infoPath = @"Dropbox\info.json";
var jsonPath = Path.Combine(Environment.GetEnvironmentVariable("LocalAppData"), infoPath);
if (!File.Exists(jsonPath)) jsonPath = Path.Combine(Environment.GetEnvironmentVariable("AppData"), infoPath);
if (!File.Exists(jsonPath)) throw new Exception("Dropbox could not be found!");
var dropboxPath = File.ReadAllText(jsonPath).Split('\"')[5].Replace(@"\\", @"\");
如果您想解析JSON,您可以使用JavaScripSerializer如下:
If you'd like to parse the JSON, you can use the JavaScripSerializer as follows:
var serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
var dictionary = (Dictionary < string, object>) serializer.DeserializeObject(File.ReadAllText(jsonPath));
var dropboxPath = (string) ((Dictionary < string, object> )dictionary["personal"])["path"];
DE preCATED SOLUTION:
您可以阅读保管箱\\ host.db文件。这是位于你的应用程序数据\\漫游路径一个Base64文件。使用此:
You can read the the dropbox\host.db file. It's a Base64 file located in your AppData\Roaming path. Use this:
var dbPath = System.IO.Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Dropbox\\host.db");
var dbBase64Text = Convert.FromBase64String(System.IO.File.ReadAllText(dbPath));
var folderPath = System.Text.ASCIIEncoding.ASCII.GetString(dbBase64Text);
希望它帮助!