本文介紹了如何使用 C# 以編程方式定位我的 Google Drive 文件夾?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
與這里.僅用于 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#?
- 注冊表?
- 環境變量?
- 等等……
推薦答案
我個人認為,最好的辦法是通過SQLite3訪問同一個文件.
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
的引用并將其包含在您的項目中以運行上述代碼.
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
這篇關于如何使用 C# 以編程方式定位我的 Google Drive 文件夾?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!