Use the OSS SDK for C# V2 to delete a single object or multiple objects from a bucket.
Prerequisites
Before you begin, make sure you have:
An OSS bucket with at least one object to delete
The
oss:DeleteObjectpermission granted to your identity. See Grant custom permissions to a RAM userAccess credentials configured as environment variables (
OSS_ACCESS_KEY_IDandOSS_ACCESS_KEY_SECRET). See Configure access credentials
Precautions
The sample code uses the China (Hangzhou) region (
cn-hangzhou) and the public endpoint by default. To access OSS from another Alibaba Cloud service in the same region, use the internal endpoint instead. See OSS regions and endpoints.
Sample code
Both examples use OSS.Configuration.LoadDefault() to initialize the client and EnvironmentVariableCredentialsProvider to load credentials from environment variables.