問題描述
與這里.僅用于 Google Drive
而不是 Dropbox
:
Similar question as here. Just for Google Drive
instead of Dropbox
:
如何使用 C# 以編程方式定位我的 Google Drive
文件夾?
How do I programmatically locate my Google Drive
folder using C#?
- 注冊表?
- 環(huán)境變量?
- 等等……
推薦答案
我個(gè)人認(rèn)為,最好的辦法是通過SQLite3訪問同一個(gè)文件.
I personally think, the best way is to access the same file through SQLite3.
string dbFilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Google\Drive\sync_config.db");
if (!File.Exists(dbFilePath))
dbFilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Google\Drive\user_default\sync_config.db");
string csGdrive = @"Data Source="+ dbFilePath + ";Version=3;New=False;Compress=True;";
SQLiteConnection con = new SQLiteConnection(csGdrive);
con.Open();
SQLiteCommand sqLitecmd = new SQLiteCommand(con);
//To retrieve the folder use the following command text
sqLitecmd.CommandText = "select * from data where entry_key='local_sync_root_path'";
SQLiteDataReader reader = sqLitecmd.ExecuteReader();
reader.Read();
//String retrieved is in the format "\?<path>" that's why I have used Substring function to extract the path alone.
Console.WriteLine("Google Drive Folder: " + reader["data_value"].ToString().Substring(4));
con.Dispose();
您可以從 獲取 .Net 的 SQLite 庫這里.還要添加對 System.Data.SQLite
的引用并將其包含在您的項(xiàng)目中以運(yùn)行上述代碼.
You can get the SQLite library for .Net from here.
Also add reference to System.Data.SQLite
and include it in your project to run the above code.
要檢索用戶,請從上述代碼中替換 entry_key='user_email'
To retrieve the user, relpace entry_key='user_email'
from the above code
這篇關(guān)于如何使用 C# 以編程方式定位我的 Google Drive 文件夾?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!