Gdrive.v3 SDKの移行情報をhttps://developers.google.com/drive/v3/web/migrationに読み込んだ後も、ParentReferenceをどのように設定できるかわからないフォルダ)を正しく検索できます。文書に記載されているようにGoogleドライブのAparent v2からC#.Netのv3にMigrate ParentReference
private string UploadToGDrive(Google.Apis.Drive.v3.DriveService service, string uploadFile, string parent)
{
var body = new Google.Apis.Drive.v3.Data.File
{
Name = Path.GetFileName(uploadFile),
Description = uploadFile,
MimeType = GetMimeType(uploadFile),
Parents = new List<ParentReference> {new ParentReference {Id = parent}}
};
}
private string GetMimeType(string fileName)
{
var mimeType = "application/unknown";
var extension = Path.GetExtension(fileName);
if (extension == null) return mimeType;
var ext = extension.ToLower();
var regKey = Registry.ClassesRoot.OpenSubKey(ext);
if (regKey?.GetValue("Content Type") != null) return mimeType;
if (regKey != null) mimeType = regKey.GetValue("Content Type").ToString();
return mimeType;
}