/// <summary> /// Permanently deletes a file by ID. Skips the trash. The currently authenticated user must own the file or be an organizer on the parent for Team Drive files. /// Documentation https://developers.google.com/drive/v2/reference/files/delete /// Generation Note: This does not always build corectly. Google needs to standardise things I need to figuer out which ones are wrong. /// </summary> /// <param name="service">Authenticated Drive service.</param> /// <param name="fileId">The ID of the file to delete.</param> /// <param name="optional">Optional paramaters.</param> public static void Delete(DriveService service, string fileId, FilesDeleteOptionalParms optional = null) { try { // Initial validation. if (service == null) { throw new ArgumentNullException("service"); } if (fileId == null) { throw new ArgumentNullException(fileId); } // Building the initial request. var request = service.Files.Delete(fileId); // Applying optional parameters to the request. request = (FilesResource.DeleteRequest)SampleHelpers.ApplyOptionalParms(request, optional); // Requesting data. request.Execute(); } catch (Exception ex) { throw new Exception("Request Files.Delete failed.", ex); } }
/// <summary> /// Permanently deletes a file owned by the user without moving it to the trash. If the file belongs to a Team Drive the user must be an organizer on the parent. If the target is a folder, all descendants owned by the user are also deleted. /// Documentation https://developers.google.com/drive/v3/reference/files/delete /// Generation Note: This does not always build corectly. Google needs to standardise things I need to figuer out which ones are wrong. /// </summary> /// <param name="service">Authenticated Drive service.</param> /// <param name="fileId">The ID of the file.</param> /// <param name="optional">Optional paramaters.</param> public async Task Delete(string fileId, FilesDeleteOptionalParms optional = null) { try { // Initial validation. if (_service == null) { throw new ArgumentNullException("service"); } if (fileId == null) { throw new ArgumentNullException(fileId); } // Building the initial request. var request = _service.Files.Delete(fileId); // Applying optional parameters to the request. request = (FilesResource.DeleteRequest)GoogleDriveFunctionsHelper.ApplyOptionalParms(request, optional); // Requesting data. await request.ExecuteAsync(); } catch (Exception ex) { throw new Exception("Request Files.Delete failed.", ex); } }