C# 如何使用C Sharp创建google电子表格?

C# 如何使用C Sharp创建google电子表格?,c#,C#,我得到这个错误 Google.GoogleAppeException:'Google.API.Requests.RequestError 找不到文件:。[404] 错误[ 调用CreateSpreadsheet()时,消息[未找到文件:.]位置[文件ID-参数]原因[未找到]域[全局] (对于我的安全性,凭据略有不同。) public Google.api.Drive.v3.Data.File CreateSheet() { string[]scopes=新字符串[]{DriveServic

我得到这个错误

Google.GoogleAppeException:'Google.API.Requests.RequestError
找不到文件:。[404]
错误[ 调用CreateSpreadsheet()时,消息[未找到文件:.]位置[文件ID-参数]原因[未找到]域[全局]

(对于我的安全性,凭据略有不同。)

public Google.api.Drive.v3.Data.File CreateSheet()
{  
string[]scopes=新字符串[]{DriveService.Scope.Drive,DriveService.Scope.DriveFile,};
var clientId=“123456337 wajklowksflmxiowerasjdflsl.apps.googleusercontent.com”;
var clientSecret=“kkslfdkiwowol_ssdwerss”;
var-credential=GoogleWebAuthorizationBroker.AuthorizationAsync(新客户端机密)
{  
ClientId=ClientId,
ClientSecret=ClientSecret
},
范围,
Environment.UserName,
取消令牌。无,
新文件数据存储(“MyAppsToken”)。结果;
DriveService _service=new DriveService(new BaseClientService.Initializer())
{  
HttpClientInitializer=凭证,
ApplicationName=“MyAppName”
});  
var _parent=”“//如果要在特定文件夹中创建电子表格,则文件夹的ID
var filename=“helloworld”;
var fileMetadata=new Google.api.Drive.v3.Data.File()
{  
Name=文件名,
MimeType=“application/vnd.google apps.spreadsheet”,
//TeamDriveId=TeamDriveId,//如果要添加到特定的团队驱动
};  
FileResource.CreateRequest请求=_service.Files.Create(fileMetadata);
request.SupportsTeamDrives=true;
fileMetadata.Parents=新列表{\u parent};//父文件夹id或TeamDriveID
request.Fields=“id”;
System.Net.ServicePointManager.ServerCertificateValidationCallback=委托(对象发送方,X509Certificate证书,X509Chain-chain,SslPolicyErrors SslPolicyErrors){return true;};
var file=request.Execute();
Show(“文件ID:+File.ID”);
返回文件;
}
public Google.Apis.Drive.v3.Data.File CreateSheet() 
{  
    string[] scopes = new string[] { DriveService.Scope.Drive,DriveService.Scope.DriveFile,};  
    var clientId = "123456337-wajklowlksflmxiowerasjdflsl.apps.googleusercontent.com";     
    var clientSecret = "kkslfdkiwowol_ssdwerss";         
    var credential = GoogleWebAuthorizationBroker.AuthorizeAsync(new ClientSecrets       
    {  
        ClientId = clientId,  
        ClientSecret = clientSecret
    },
    scopes,  
    Environment.UserName,
    CancellationToken.None,
    new FileDataStore("MyAppsToken")).Result;  

    DriveService _service = new DriveService(new BaseClientService.Initializer()  
    {  
        HttpClientInitializer = credential,  
        ApplicationName = "MyAppName"
    });  
           
    var _parent = ""; //ID of folder if you want to create spreadsheet in specific folder
    var filename = "helloworld";
    var fileMetadata = new Google.Apis.Drive.v3.Data.File()  
    {  
        Name = filename,  
        MimeType = "application/vnd.google-apps.spreadsheet",  
        //TeamDriveId = teamDriveID, // IF you want to add to specific team drive  
    };  

    FilesResource.CreateRequest request = _service.Files.Create(fileMetadata);  
    request.SupportsTeamDrives = true;  
    fileMetadata.Parents = new List<string> { _parent }; // Parent folder id or TeamDriveID  
    request.Fields = "id";  
    System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate (object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; };  
    var file = request.Execute();  
    MessageBox.Show("File ID: " + file.Id);  
    return file;  
}