Пример #1
0
 //метод записи файла
 private void WriteFile(DriveId folderBackUpId, string filename, IDriveApiDriveContentsResult content)
 {
     try
     {
         byte[] bytes = System.IO.File.ReadAllBytes(pathToDb);
         string file  = Convert.ToBase64String(bytes);
         using (var writer = new OutputStreamWriter(content.DriveContents.OutputStream))
         {
             writer.Write(file);
             writer.Close();
         }
         MetadataChangeSet changeSet = new MetadataChangeSet.Builder()
                                       .SetTitle(filename)
                                       .SetMimeType("application/octet-stream")
                                       .Build();
         IDriveFolder driveFolder = null;
         //получаем папку по ID
         driveFolder = driveFolder ?? folderBackUpId.AsDriveFolder();
         //если папка не ноль то создаем файл
         if (driveFolder != null)
         {
             var s = driveFolder.CreateFile(_googleApiClient, changeSet, content.DriveContents);
             CreateAlertDialog("", successMessage);
         }
     }
     catch (Exception er)
     {
         CreateAlertDialog("", errorMessage + er.Message);
     }
 }
 public static async Task <IDriveFolderDriveFileResult> CreateFileAsync(this IDriveFolder api, GoogleApiClient apiClient, MetadataChangeSet changeSet, IDriveContents driveContents, ExecutionOptions executionOptions)
 {
     return((await api.CreateFile(apiClient, changeSet, driveContents, executionOptions)).JavaCast <IDriveFolderDriveFileResult> ());
 }