AWS SDK Version 3 for .NET
API Reference

AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.

Provides access to read and write to the shared credentials INI file. The file is read, parsed, and validated at construction time. Changes can be made using the RegisterProfile() and UnregisterProfile() methods. This class is not threadsafe.

Inheritance Hierarchy

System.Object
  Amazon.Runtime.CredentialManagement.SharedCredentialsFile

Namespace: Amazon.Runtime.CredentialManagement
Assembly: AWSSDK.Core.dll
Version: 3.x.y.z

Syntax

C#
public class SharedCredentialsFile
         ICredentialProfileSource, ICredentialProfileStore

The SharedCredentialsFile type exposes the following members

Constructors

NameDescription
Public Method SharedCredentialsFile()

Construct a new SharedCredentialsFile in the default location.

Public Method SharedCredentialsFile(string)

Construct a new SharedCredentialsFile.

Properties

NameTypeDescription
Public Property ConfigFilePath System.String

The path to the config file

Public Property Static Property DefaultConfigFilePath System.String

The default file path for the config file. By default it searches in ~/.aws/config

Public Property Static Property DefaultFilePath System.String

The default file path for the credentials file. By default it searches for ~/.aws/credentials. This behavior can be overriden.

Public Property FilePath System.String

The path to the credentials file

Methods

Note:

Asynchronous operations (methods ending with Async) in the table below are for .NET 4.5 or higher. For .NET 3.5 the SDK follows the standard naming convention of BeginMethodName and EndMethodName to indicate asynchronous operations - these method pairs are not shown in the table below.

NameDescription
Public Method CopyProfile(string, string)

Make a copy of the profile with fromProfileName called toProfileName.

Public Method CopyProfile(string, string, bool)

Make a copy of the profile with fromProfileName called toProfileName.

Public Method ListProfileNames()
Public Method ListProfiles()
Public Method RegisterProfile(CredentialProfile)

Add the profile given. If the profile already exists, update it.

Public Method RenameProfile(string, string)

Rename the profile with oldProfileName to newProfileName.

Public Method RenameProfile(string, string, bool)

Rename the profile with oldProfileName to newProfileName.

Public Method TryGetProfile(string, out CredentialProfile)
Public Method UnregisterProfile(string)

Deletes the section with the given ProfileName from the SharedCredentialsFile, if one exists.

Fields

NameTypeDescription
Field Static Field DefaultConfigDirectory System.String

The default directory for the config file. By default it searches in ~/.aws This behavior can be overriden.

Field Static Field DefaultDirectory System.String

The default directory for the credentials file. By default it searches in ~/.aws. This behavior can be overridden.

Field Static Field DefaultProfileName System.String
Field Static Field SharedConfigFileEnvVar System.String
Field Static Field SharedCredentialsFileEnvVar System.String

Version Information

.NET Core App:
Supported in: 3.1

.NET Standard:
Supported in: 2.0

.NET Framework:
Supported in: 4.5, 4.0, 3.5