使用.NET更新Google云端硬盘上的文件内容

时间:2020-08-25 12:23:19

标签: c# google-drive-api

我要在特定文件内容中添加文本。

我用过:

  var file = await dataService.Files.Get(fileId).ExecuteAsync();
  if (file == null)
  {
    throw new Exception(nameof(fileId));
  }

  using (var stream = new MemoryStream())
  {
    using (var sw = new StreamWriter(stream, Encoding.UTF8))
    {
      sw.Write(content); //there is a simple text like: bblablllbalblba

      var request = dataService.Files.Update(file, fileId, stream, file.MimeType);
      await request.UploadAsync();
    }
  }

,但似乎内容未更新/编写。我没有任何错误。

我错了吗?

0 个答案:

没有答案
相关问题