Removes the specified objects from Amazon S3.
            
 Declaration Syntax
 Declaration Syntax| C# | 
public DeleteObjectsResponse DeleteObjects( DeleteObjectsRequest request )
 Parameters
 Parameters- request (DeleteObjectsRequest)
- The DeleteObjectsRequest that defines the parameters of the operation.
 Return Value
 Return ValueReturns a DeleteObjectsResponse from S3.
 Remarks
 RemarksThe DeleteObjects operation removes the specified object from Amazon S3. Once deleted, there is no method to restore or undelete the objects.
DeleteObjectsException will be thrown if any of the deletes fail.
 Examples
 Examples
          This example shows how to delete multiple objects in a single request. 
          Note that the call may not delete all objects. In that case, an exception
          will be thrown. This exception will contain the list of encountered
          delete errors.
        
 CopyDeleteObjects sample
CopyDeleteObjects sample// Create a client AmazonS3Client client = new AmazonS3Client(); // Create a DeleteObject request DeleteObjectsRequest request = new DeleteObjectsRequest { BucketName = "SampleBucket", Keys = new List<KeyVersion> { new KeyVersion("Item1"), // Versioned item new KeyVersion("Item2", "Rej8CiBxcZKVK81cLr39j27Y5FVXghDK"), // Item in subdirectory new KeyVersion("Logs/error.txt") } }; try { // Issue request DeleteObjectsResponse response = client.DeleteObjects(request); } catch (DeleteObjectsException doe) { // Catch error and list error details DeleteObjectsErrorResponse errorResponse = doe.ErrorResponse; foreach (DeletedObject deletedObject in errorResponse.DeletedObjects) { Console.WriteLine("Deleted item " + deletedObject.Key); } foreach (DeleteError deleteError in errorResponse.DeleteErrors) { Console.WriteLine("Error deleting item " + deleteError.Key); Console.WriteLine(" Code - " + deleteError.Code); Console.WriteLine(" Message - " + deleteError.Message); } }
 Exceptions
 Exceptions| Exception | Condition | 
|---|---|
| ArgumentNullException | |
| WebException | |
| AmazonS3Exception | |
| DeleteObjectsException | If any objects are not deleted during the operation. | 
 See Also
 See AlsoDeleteObjects()()()()