在 C# 中的 Google Drive Api v3 中获取 root id

Jul*_*cev 4 c# google-drive-api

我正在寻找一种在 Google Drive Api v3 中查找根文件夹 ID 的方法

在 Google Drive Api v2 中,有一种直接获取根文件夹 ID 的方法:

string rootFolderID = (ServiceV2.About.Get().Execute()).RootFolderId;
Run Code Online (Sandbox Code Playgroud)

如何在 v3 中找到 root id?

Tan*_*ike 5

这个答案怎么样?

官方文档是这样说的。

您可以使用别名 root 来引用提供文件 ID 的任何位置的根文件夹

所以你可以使用root作为根文件夹ID。

笔记:

  • 如果您需要检索实际的根文件夹 ID 而不是root,使用 files.get 方法怎么样?
    • service.Files.Get("root").Execute()
    • 这样,您就可以检索实际的根文件夹 ID。

参考:

如果我误解了你的问题,我深表歉意。