Class ShareFileClient
The ShareFileClient allows you to manipulate Azure Storage files.
public class ShareFileClient
- Inheritance
-
ShareFileClient
- Inherited Members
- Extension Methods
Constructors
ShareFileClient()
Initializes a new instance of the ShareFileClient class for mocking.
protected ShareFileClient()
ShareFileClient(string, string, string)
Initializes a new instance of the ShareFileClient class.
public ShareFileClient(string connectionString, string shareName, string filePath)
Parameters
connectionString
stringA connection string includes the authentication information required for your application to access data in an Azure Storage account at runtime.
For more information, see Configure Azure Storage connection strings
shareName
stringThe name of the share in the storage account to reference.
filePath
stringThe path of the file in the storage account to reference.
ShareFileClient(string, string, string, ShareClientOptions)
Initializes a new instance of the ShareFileClient class.
public ShareFileClient(string connectionString, string shareName, string filePath, ShareClientOptions options)
Parameters
connectionString
stringA connection string includes the authentication information required for your application to access data in an Azure Storage account at runtime.
For more information, see Configure Azure Storage connection strings
shareName
stringThe name of the share in the storage account to reference.
filePath
stringThe path of the file in the storage account to reference.
options
ShareClientOptionsOptional ShareClientOptions that define the transport pipeline policies for authentication, retries, etc., that are applied to every request.
ShareFileClient(Uri, AzureSasCredential, ShareClientOptions)
Initializes a new instance of the ShareFileClient class.
public ShareFileClient(Uri fileUri, AzureSasCredential credential, ShareClientOptions options = null)
Parameters
fileUri
UriA Uri referencing the file that includes the name of the account, the name of the share, and the path of the file. Must not contain shared access signature, which should be passed in the second parameter.
credential
AzureSasCredentialThe shared access signature credential used to sign requests.
options
ShareClientOptionsOptional ShareClientOptions that define the transport pipeline policies for authentication, retries, etc., that are applied to every request.
Remarks
This constructor should only be used when shared access signature needs to be updated during lifespan of this client.
ShareFileClient(Uri, TokenCredential, ShareClientOptions)
Initializes a new instance of the ShareFileClient class.
Note that ShareTokenIntent is currently required for token authentication.
public ShareFileClient(Uri fileUri, TokenCredential credential, ShareClientOptions options = null)
Parameters
fileUri
UriA Uri referencing the file that includes the name of the account, the name of the share, and the path of the file.
credential
TokenCredentialThe token credential used to sign requests.
options
ShareClientOptionsOptional client options that define the transport pipeline policies for authentication, retries, etc., that are applied to every request.
ShareFileClient(Uri, ShareClientOptions)
Initializes a new instance of the ShareFileClient class.
public ShareFileClient(Uri fileUri, ShareClientOptions options = null)
Parameters
fileUri
UriA Uri referencing the file that includes the name of the account, the name of the share, and the path of the file.
options
ShareClientOptionsOptional ShareClientOptions that define the transport pipeline policies for authentication, retries, etc., that are applied to every request.
ShareFileClient(Uri, StorageSharedKeyCredential, ShareClientOptions)
Initializes a new instance of the ShareFileClient class.
public ShareFileClient(Uri fileUri, StorageSharedKeyCredential credential, ShareClientOptions options = null)
Parameters
fileUri
UriA Uri referencing the file that includes the name of the account, the name of the share, and the path of the file.
credential
StorageSharedKeyCredentialThe shared key credential used to sign requests.
options
ShareClientOptionsOptional ShareClientOptions that define the transport pipeline policies for authentication, retries, etc., that are applied to every request.
Properties
AccountName
Gets the Storage account name corresponding to the file client.
public virtual string AccountName { get; }
Property Value
CanGenerateSasUri
Indicates whether the client is able to generate a SAS uri. Client can generate a SAS url if it is authenticated with a Azure.Storage.StorageSharedKeyCredential.
public virtual bool CanGenerateSasUri { get; }
Property Value
Name
Gets the name of the file.
public virtual string Name { get; }
Property Value
Path
Gets the path of the file.
public virtual string Path { get; }
Property Value
ShareName
Gets the share name corresponding to the file client.
public virtual string ShareName { get; }
Property Value
Uri
Gets the directory's primary Uri endpoint.
public virtual Uri Uri { get; }
Property Value
- Uri
Methods
AbortCopy(string, ShareFileRequestConditions, CancellationToken)
Attempts to cancel a pending copy that was previously started and leaves a destination file with zero length and full metadata.
For more information, see Abort Copy File.
public virtual Response AbortCopy(string copyId, ShareFileRequestConditions conditions = null, CancellationToken cancellationToken = default)
Parameters
copyId
stringString identifier for the copy operation.
conditions
ShareFileRequestConditionsOptional ShareFileRequestConditions to add conditions on creating the file.
cancellationToken
CancellationTokenOptional CancellationToken to propagate notifications that the operation should be cancelled.
Returns
- Response
A Azure.Response on successfully aborting.
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
AbortCopyAsync(string, ShareFileRequestConditions, CancellationToken)
Attempts to cancel a pending copy that was previously started and leaves a destination file with zero length and full metadata.
For more information, see Abort Copy File.
public virtual Task<Response> AbortCopyAsync(string copyId, ShareFileRequestConditions conditions = null, CancellationToken cancellationToken = default)
Parameters
copyId
stringString identifier for the copy operation.
conditions
ShareFileRequestConditionsOptional ShareFileRequestConditions to add conditions on creating the file.
cancellationToken
CancellationTokenOptional CancellationToken to propagate notifications that the operation should be cancelled.
Returns
- Task<Response>
A Azure.Response on successfully aborting.
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
ClearRange(HttpRange, ShareFileRequestConditions, CancellationToken)
The ClearRange(HttpRange, ShareFileRequestConditions, CancellationToken)
operation clears the range
of a file.
For more information, see Put Range.
public virtual Response<ShareFileUploadInfo> ClearRange(HttpRange range, ShareFileRequestConditions conditions = null, CancellationToken cancellationToken = default)
Parameters
range
HttpRangeSpecifies the range of bytes to be cleared. Both the start and end of the range must be specified.
conditions
ShareFileRequestConditionsOptional ShareFileRequestConditions to add conditions on creating the file.
cancellationToken
CancellationTokenOptional CancellationToken to propagate notifications that the operation should be cancelled.
Returns
- Response<ShareFileUploadInfo>
A Azure.Response<> describing the state of the file.
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
ClearRangeAsync(HttpRange, ShareFileRequestConditions, CancellationToken)
The ClearRangeAsync(HttpRange, ShareFileRequestConditions, CancellationToken)
operation clears the range
of a file.
For more information, see Put Range.
public virtual Task<Response<ShareFileUploadInfo>> ClearRangeAsync(HttpRange range, ShareFileRequestConditions conditions = null, CancellationToken cancellationToken = default)
Parameters
range
HttpRangeSpecifies the range of bytes to be cleared. Both the start and end of the range must be specified.
conditions
ShareFileRequestConditionsOptional ShareFileRequestConditions to add conditions on creating the file.
cancellationToken
CancellationTokenOptional CancellationToken to propagate notifications that the operation should be cancelled.
Returns
- Task<Response<ShareFileUploadInfo>>
A Azure.Response<> describing the state of the file.
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
Create(long, ShareFileHttpHeaders, IDictionary<string, string>, FileSmbProperties, string, ShareFileRequestConditions, CancellationToken)
Creates a new file or replaces an existing file.
For more information, see Create File.
public virtual Response<ShareFileInfo> Create(long maxSize, ShareFileHttpHeaders httpHeaders = null, IDictionary<string, string> metadata = null, FileSmbProperties smbProperties = null, string filePermission = null, ShareFileRequestConditions conditions = null, CancellationToken cancellationToken = default)
Parameters
maxSize
longRequired. Specifies the maximum size for the file in bytes. The max supported file size is 4 TiB.
httpHeaders
ShareFileHttpHeadersOptional standard HTTP header properties that can be set for the file.
metadata
IDictionary<string, string>Optional custom metadata to set for the file.
smbProperties
FileSmbPropertiesOptional SMB properties to set for the file.
filePermission
stringOptional file permission to set for the file.
conditions
ShareFileRequestConditionsOptional ShareFileRequestConditions to add conditions on creating the file.
cancellationToken
CancellationTokenOptional CancellationToken to propagate notifications that the operation should be cancelled.
Returns
- Response<ShareFileInfo>
A Azure.Response<> describing the state of the file.
Remarks
This method only initializes the file. To add content, use Azure.Storage.Files.Shares.ShareFileClient.UploadRangeAsync(Azure.HttpRange,System.IO.Stream,System.Byte[],System.IProgress{System.Int64},Azure.Storage.Files.Shares.Models.ShareFileRequestConditions,System.Threading.CancellationToken).
CreateAsync(long, ShareFileHttpHeaders, IDictionary<string, string>, FileSmbProperties, string, ShareFileRequestConditions, CancellationToken)
Creates a new file or replaces an existing file.
For more information, see Create File.
public virtual Task<Response<ShareFileInfo>> CreateAsync(long maxSize, ShareFileHttpHeaders httpHeaders = null, IDictionary<string, string> metadata = null, FileSmbProperties smbProperties = null, string filePermission = null, ShareFileRequestConditions conditions = null, CancellationToken cancellationToken = default)
Parameters
maxSize
longRequired. Specifies the maximum size for the file in bytes. The max supported file size is 4 TiB.
httpHeaders
ShareFileHttpHeadersOptional standard HTTP header properties that can be set for the file.
metadata
IDictionary<string, string>Optional custom metadata to set for the file.
smbProperties
FileSmbPropertiesOptional SMB properties to set for the file.
filePermission
stringOptional file permission to set for the file.
conditions
ShareFileRequestConditionsOptional ShareFileRequestConditions to add conditions on creating the file.
cancellationToken
CancellationTokenOptional CancellationToken to propagate notifications that the operation should be cancelled.
Returns
- Task<Response<ShareFileInfo>>
A Azure.Response<> describing the state of the file.
Remarks
This method only initializes the file. To add content, use Azure.Storage.Files.Shares.ShareFileClient.UploadRangeAsync(Azure.HttpRange,System.IO.Stream,System.Byte[],System.IProgress{System.Int64},Azure.Storage.Files.Shares.Models.ShareFileRequestConditions,System.Threading.CancellationToken).
Delete(ShareFileRequestConditions, CancellationToken)
The Delete(ShareFileRequestConditions, CancellationToken) operation immediately removes the file from the storage account.
For more information, see Delete File.
public virtual Response Delete(ShareFileRequestConditions conditions = null, CancellationToken cancellationToken = default)
Parameters
conditions
ShareFileRequestConditionsOptional ShareFileRequestConditions to add conditions on creating the file.
cancellationToken
CancellationTokenOptional CancellationToken to propagate notifications that the operation should be cancelled.
Returns
- Response
A Azure.Response on successfully deleting.
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
DeleteAsync(ShareFileRequestConditions, CancellationToken)
The DeleteAsync(ShareFileRequestConditions, CancellationToken) operation immediately removes the file from the storage account.
For more information, see Delete File.
public virtual Task<Response> DeleteAsync(ShareFileRequestConditions conditions = null, CancellationToken cancellationToken = default)
Parameters
conditions
ShareFileRequestConditionsOptional ShareFileRequestConditions to add conditions on creating the file.
cancellationToken
CancellationTokenOptional CancellationToken to propagate notifications that the operation should be cancelled.
Returns
- Task<Response>
A Azure.Response on successfully deleting.
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
DeleteIfExists(ShareFileRequestConditions, CancellationToken)
The DeleteIfExists(ShareFileRequestConditions, CancellationToken) operation immediately removes the file from the storage account, if it exists.
For more information, see Delete File.
public virtual Response<bool> DeleteIfExists(ShareFileRequestConditions conditions = null, CancellationToken cancellationToken = default)
Parameters
conditions
ShareFileRequestConditionsOptional ShareFileRequestConditions to add conditions on creating the file.
cancellationToken
CancellationTokenOptional CancellationToken to propagate notifications that the operation should be cancelled.
Returns
- Response<bool>
True if the file existed.
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
DeleteIfExistsAsync(ShareFileRequestConditions, CancellationToken)
The DeleteIfExists(ShareFileRequestConditions, CancellationToken) operation immediately removes the file from the storage account, if it exists.
For more information, see Delete File.
public virtual Task<Response<bool>> DeleteIfExistsAsync(ShareFileRequestConditions conditions = null, CancellationToken cancellationToken = default)
Parameters
conditions
ShareFileRequestConditionsOptional ShareFileRequestConditions to add conditions on creating the file.
cancellationToken
CancellationTokenOptional CancellationToken to propagate notifications that the operation should be cancelled.
Returns
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
Download(ShareFileDownloadOptions, CancellationToken)
The Download(ShareFileDownloadOptions, CancellationToken) operation reads or downloads a file from the system, including its metadata and properties.
For more information, see Get File.
public virtual Response<ShareFileDownloadInfo> Download(ShareFileDownloadOptions options = null, CancellationToken cancellationToken = default)
Parameters
options
ShareFileDownloadOptionsOptional parameters.
cancellationToken
CancellationTokenOptional CancellationToken to propagate notifications that the operation should be cancelled.
Returns
- Response<ShareFileDownloadInfo>
A Azure.Response<> describing the downloaded file. Content contains the file's data.
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
DownloadAsync(ShareFileDownloadOptions, CancellationToken)
The DownloadAsync(ShareFileDownloadOptions, CancellationToken) operation reads or downloads a file from the system, including its metadata and properties.
For more information, see Get File.
public virtual Task<Response<ShareFileDownloadInfo>> DownloadAsync(ShareFileDownloadOptions options = null, CancellationToken cancellationToken = default)
Parameters
options
ShareFileDownloadOptionsOptional parameters.
cancellationToken
CancellationTokenOptional CancellationToken to propagate notifications that the operation should be cancelled.
Returns
- Task<Response<ShareFileDownloadInfo>>
A Azure.Response<> describing the downloaded file. Content contains the file's data.
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
Exists(CancellationToken)
The Exists(CancellationToken) operation can be called on a ShareFileClient to see if the associated file exists in the share on the storage account.
public virtual Response<bool> Exists(CancellationToken cancellationToken = default)
Parameters
cancellationToken
CancellationTokenOptional CancellationToken to propagate notifications that the operation should be cancelled.
Returns
- Response<bool>
Returns true if the file exists.
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
ExistsAsync(CancellationToken)
The Exists(CancellationToken) operation can be called on a ShareFileClient to see if the associated file exists in the share on the storage account.
public virtual Task<Response<bool>> ExistsAsync(CancellationToken cancellationToken = default)
Parameters
cancellationToken
CancellationTokenOptional CancellationToken to propagate notifications that the operation should be cancelled.
Returns
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
ForceCloseAllHandles(CancellationToken)
The ForceCloseAllHandles(CancellationToken) operation closes all handles opened on a file at the service.
This API is intended to be used alongside GetHandlesAsync(CancellationToken) to force close handles that block operations. These handles may have leaked or been lost track of by SMB clients. The API has client-side impact on the handle being closed, including user visible errors due to failed attempts to read or write files. This API is not intended for use as a replacement or alternative for SMB close.
For more information, see Force Close Handles.
public virtual CloseHandlesResult ForceCloseAllHandles(CancellationToken cancellationToken = default)
Parameters
cancellationToken
CancellationTokenOptional CancellationToken to propagate notifications that the operation should be cancelled.
Returns
- CloseHandlesResult
A CloseHandlesResult describing the status of the ForceCloseAllHandles(CancellationToken) operation.
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
ForceCloseAllHandlesAsync(CancellationToken)
The ForceCloseAllHandlesAsync(CancellationToken) operation closes all handles opened on a file at the service.
This API is intended to be used alongside GetHandlesAsync(CancellationToken) to force close handles that block operations. These handles may have leaked or been lost track of by SMB clients. The API has client-side impact on the handle being closed, including user visible errors due to failed attempts to read or write files. This API is not intended for use as a replacement or alternative for SMB close.
For more information, see Force Close Handles.
public virtual Task<CloseHandlesResult> ForceCloseAllHandlesAsync(CancellationToken cancellationToken = default)
Parameters
cancellationToken
CancellationTokenOptional CancellationToken to propagate notifications that the operation should be cancelled.
Returns
- Task<CloseHandlesResult>
A CloseHandlesResult describing the status of the ForceCloseAllHandlesAsync(CancellationToken) operation.
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
ForceCloseHandle(string, CancellationToken)
The ForceCloseHandle(string, CancellationToken) operation closes a handle opened on a file
at the service. It supports closing a single handle specified by handleId
.
This API is intended to be used alongside GetHandlesAsync(CancellationToken) to force close handles that block operations. These handles may have leaked or been lost track of by SMB clients. The API has client-side impact on the handle being closed, including user visible errors due to failed attempts to read or write files. This API is not intended for use as a replacement or alternative for SMB close.
For more information, see Force Close Handles.
public virtual Response<CloseHandlesResult> ForceCloseHandle(string handleId, CancellationToken cancellationToken = default)
Parameters
handleId
stringSpecifies the handle ID to be closed.
cancellationToken
CancellationTokenOptional CancellationToken to propagate notifications that the operation should be cancelled.
Returns
- Response<CloseHandlesResult>
A Azure.Response<> describing the status of the ForceCloseHandle(string, CancellationToken) operation.
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
ForceCloseHandleAsync(string, CancellationToken)
The ForceCloseHandleAsync(string, CancellationToken) operation closes a handle opened on a file
at the service. It supports closing a single handle specified by handleId
.
This API is intended to be used alongside GetHandlesAsync(CancellationToken) to force close handles that block operations. These handles may have leaked or been lost track of by SMB clients. The API has client-side impact on the handle being closed, including user visible errors due to failed attempts to read or write files. This API is not intended for use as a replacement or alternative for SMB close.
For more information, see Force Close Handles.
public virtual Task<Response<CloseHandlesResult>> ForceCloseHandleAsync(string handleId, CancellationToken cancellationToken = default)
Parameters
handleId
stringSpecifies the handle ID to be closed.
cancellationToken
CancellationTokenOptional CancellationToken to propagate notifications that the operation should be cancelled.
Returns
- Task<Response<CloseHandlesResult>>
A Azure.Response<> describing the status of the ForceCloseHandleAsync(string, CancellationToken) operation.
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
GenerateSasUri(ShareFileSasPermissions, DateTimeOffset)
The GenerateSasUri(ShareFileSasPermissions, DateTimeOffset) returns a Uri that generates a Share File Service Shared Access Signature (SAS) Uri based on the Client properties and parameters passed. The SAS is signed by the shared key credential of the client.
To check if the client is able to sign a Service Sas see CanGenerateSasUri.
For more information, see Constructing a service SAS.
public virtual Uri GenerateSasUri(ShareFileSasPermissions permissions, DateTimeOffset expiresOn)
Parameters
permissions
ShareFileSasPermissionsRequired. Specifies the list of permissions to be associated with the SAS. See ShareFileSasPermissions.
expiresOn
DateTimeOffsetRequired. Specifies the time at which the SAS becomes invalid. This field must be omitted if it has been specified in an associated stored access policy.
Returns
- Uri
A Uri containing the SAS Uri.
Remarks
A Exception will be thrown if a failure occurs.
GenerateSasUri(ShareSasBuilder)
The GenerateSasUri(ShareSasBuilder) returns a Uri that generates a Share File Service Shared Access Signature (SAS) Uri based on the Client properties and and builder. The SAS is signed by the shared key credential of the client.
To check if the client is able to sign a Service Sas see CanGenerateSasUri.
For more information, see Constructing a Service SAS.
public virtual Uri GenerateSasUri(ShareSasBuilder builder)
Parameters
builder
ShareSasBuilderUsed to generate a Shared Access Signature (SAS)
Returns
- Uri
A ShareSasBuilder on successfully deleting.
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
GetCopyAuthorizationHeaderAsync(ShareFileClient, CancellationToken)
Get a ShareFileClient's Azure.HttpAuthorization for passing the authorization when performing service to service copy where OAuth is necessary to authenticate the source.
protected static Task<HttpAuthorization> GetCopyAuthorizationHeaderAsync(ShareFileClient client, CancellationToken cancellationToken = default)
Parameters
client
ShareFileClientThe storage client which to generate the authorization header off of.
cancellationToken
CancellationTokenOptional CancellationToken to propagate notifications that the operation should be cancelled.
Returns
- Task<HttpAuthorization>
The BlobServiceClient's HttpPipeline.
GetHandles(CancellationToken)
The GetHandles(CancellationToken) operation returns an async sequence of the open handles on a directory or a file. Enumerating the handles may make multiple requests to the service while fetching all the values.
For more information, see List Handles.
public virtual Pageable<ShareFileHandle> GetHandles(CancellationToken cancellationToken = default)
Parameters
cancellationToken
CancellationTokenOptional CancellationToken to propagate notifications that the operation should be cancelled.
Returns
- Pageable<ShareFileHandle>
An IEnumerable<T> of Azure.Response<> describing the handles in the directory.
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
GetHandlesAsync(CancellationToken)
The GetHandlesAsync(CancellationToken) operation returns an async sequence of the open handles on a directory or a file. Enumerating the handles may make multiple requests to the service while fetching all the values.
For more information, see List Handles.
public virtual AsyncPageable<ShareFileHandle> GetHandlesAsync(CancellationToken cancellationToken = default)
Parameters
cancellationToken
CancellationTokenOptional CancellationToken to propagate notifications that the operation should be cancelled.
Returns
- AsyncPageable<ShareFileHandle>
A Azure.AsyncPageable<> describing the handles on the file.
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
GetParentShareClientCore()
Create a new ShareClient that pointing to this ShareFileClient's parent container. The new ShareClient uses the same request policy pipeline as the ShareFileClient.
protected virtual ShareClient GetParentShareClientCore()
Returns
- ShareClient
A new ShareFileClient instance.
GetParentShareDirectoryClientCore()
Create a new ShareDirectoryClient that pointing to this ShareFileClient's parent container. The new ShareDirectoryClient uses the same request policy pipeline as the ShareFileClient.
protected virtual ShareDirectoryClient GetParentShareDirectoryClientCore()
Returns
- ShareDirectoryClient
A new ShareFileClient instance.
GetProperties(ShareFileRequestConditions, CancellationToken)
The GetProperties(ShareFileRequestConditions, CancellationToken) operation returns all user-defined metadata, standard HTTP properties, and system properties for the file. It does not return the content of the file.
For more information, see Get File Properties.
public virtual Response<ShareFileProperties> GetProperties(ShareFileRequestConditions conditions = null, CancellationToken cancellationToken = default)
Parameters
conditions
ShareFileRequestConditionsOptional ShareFileRequestConditions to add conditions on creating the file.
cancellationToken
CancellationTokenOptional CancellationToken to propagate notifications that the operation should be cancelled.
Returns
- Response<ShareFileProperties>
A Azure.Response<> describing the file's properties.
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
GetPropertiesAsync(ShareFileRequestConditions, CancellationToken)
The GetPropertiesAsync(ShareFileRequestConditions, CancellationToken) operation returns all user-defined metadata, standard HTTP properties, and system properties for the file. It does not return the content of the file.
For more information, see Get File Properties.
public virtual Task<Response<ShareFileProperties>> GetPropertiesAsync(ShareFileRequestConditions conditions = null, CancellationToken cancellationToken = default)
Parameters
conditions
ShareFileRequestConditionsOptional ShareFileRequestConditions to add conditions on creating the file.
cancellationToken
CancellationTokenOptional CancellationToken to propagate notifications that the operation should be cancelled.
Returns
- Task<Response<ShareFileProperties>>
A Azure.Response<> describing the file's properties.
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
GetRangeList(ShareFileGetRangeListOptions, CancellationToken)
Returns the list of valid ranges for a file.
For more information, see List Ranges.
public virtual Response<ShareFileRangeInfo> GetRangeList(ShareFileGetRangeListOptions options = null, CancellationToken cancellationToken = default)
Parameters
options
ShareFileGetRangeListOptionsOptional parameters.
cancellationToken
CancellationTokenOptional CancellationToken to propagate notifications that the operation should be cancelled.
Returns
- Response<ShareFileRangeInfo>
A Azure.Response<> describing the valid ranges for this file.
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
GetRangeListAsync(ShareFileGetRangeListOptions, CancellationToken)
Returns the list of valid ranges for a file.
For more information, see List Ranges.
public virtual Task<Response<ShareFileRangeInfo>> GetRangeListAsync(ShareFileGetRangeListOptions options = null, CancellationToken cancellationToken = default)
Parameters
options
ShareFileGetRangeListOptionsOptional parameters.
cancellationToken
CancellationTokenOptional CancellationToken to propagate notifications that the operation should be cancelled.
Returns
- Task<Response<ShareFileRangeInfo>>
A Azure.Response<> describing the valid ranges for this file.
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
GetRangeListDiff(ShareFileGetRangeListDiffOptions, CancellationToken)
Returns the list of ranges that have changed in the file since previousSnapshot was taken.
For more information, see List Ranges.
public virtual Response<ShareFileRangeInfo> GetRangeListDiff(ShareFileGetRangeListDiffOptions options = null, CancellationToken cancellationToken = default)
Parameters
options
ShareFileGetRangeListDiffOptionsOptional parameters.
cancellationToken
CancellationTokenOptional CancellationToken to propagate notifications that the operation should be cancelled.
Returns
- Response<ShareFileRangeInfo>
A Azure.Response<> describing the valid ranges for this file.
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
GetRangeListDiffAsync(ShareFileGetRangeListDiffOptions, CancellationToken)
Returns the list of ranges that have changed in the file since previousSnapshot was taken.
For more information, see List Ranges.
public virtual Task<Response<ShareFileRangeInfo>> GetRangeListDiffAsync(ShareFileGetRangeListDiffOptions options = null, CancellationToken cancellationToken = default)
Parameters
options
ShareFileGetRangeListDiffOptionsOptional parameters.
cancellationToken
CancellationTokenOptional CancellationToken to propagate notifications that the operation should be cancelled.
Returns
- Task<Response<ShareFileRangeInfo>>
A Azure.Response<> describing the valid ranges for this file.
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
OpenRead(ShareFileOpenReadOptions, CancellationToken)
Opens a stream for reading from the file. The stream will only download the file as the stream is read from.
public virtual Stream OpenRead(ShareFileOpenReadOptions options, CancellationToken cancellationToken = default)
Parameters
options
ShareFileOpenReadOptionsOptional parameters.
cancellationToken
CancellationTokenOptional CancellationToken to propagate notifications that the operation should be cancelled.
Returns
- Stream
Returns a stream that will download the file as the stream is read from.
Remarks
The stream returned might throw ShareFileModifiedException if the file is concurrently modified and ShareFileOpenReadOptions don't allow modification.
A Azure.RequestFailedException will be thrown if other failures occur.
OpenReadAsync(ShareFileOpenReadOptions, CancellationToken)
Opens a stream for reading from the file. The stream will only download the file as the stream is read from.
public virtual Task<Stream> OpenReadAsync(ShareFileOpenReadOptions options, CancellationToken cancellationToken = default)
Parameters
options
ShareFileOpenReadOptionsOptional parameters.
cancellationToken
CancellationTokenOptional CancellationToken to propagate notifications that the operation should be cancelled.
Returns
Remarks
The stream returned might throw ShareFileModifiedException if the file is concurrently modified and ShareFileOpenReadOptions don't allow modification.
A Azure.RequestFailedException will be thrown if other failures occur.
OpenWrite(bool, long, ShareFileOpenWriteOptions, CancellationToken)
Opens a stream for writing to the file.
public virtual Stream OpenWrite(bool overwrite, long position, ShareFileOpenWriteOptions options = null, CancellationToken cancellationToken = default)
Parameters
overwrite
boolWhether an existing blob should be deleted and recreated.
position
longThe offset within the blob to begin writing from.
options
ShareFileOpenWriteOptionsOptional parameters.
cancellationToken
CancellationTokenOptional CancellationToken to propagate notifications that the operation should be cancelled.
Returns
- Stream
A stream to write to the file.
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
OpenWriteAsync(bool, long, ShareFileOpenWriteOptions, CancellationToken)
Opens a stream for writing to the file.
public virtual Task<Stream> OpenWriteAsync(bool overwrite, long position, ShareFileOpenWriteOptions options = null, CancellationToken cancellationToken = default)
Parameters
overwrite
boolWhether an existing blob should be deleted and recreated.
position
longThe offset within the blob to begin writing from.
options
ShareFileOpenWriteOptionsOptional parameters.
cancellationToken
CancellationTokenOptional CancellationToken to propagate notifications that the operation should be cancelled.
Returns
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
Rename(string, ShareFileRenameOptions, CancellationToken)
Renames a file. This API does not support renaming a file from one share to another, or between storage accounts.
public virtual Response<ShareFileClient> Rename(string destinationPath, ShareFileRenameOptions options = null, CancellationToken cancellationToken = default)
Parameters
destinationPath
stringThe destination path to rename the file to.
options
ShareFileRenameOptionsOptional parameters.
cancellationToken
CancellationTokenOptional CancellationToken to propagate notifications that the operation should be cancelled.
Returns
- Response<ShareFileClient>
A Azure.Response<> pointed at the newly renamed File.
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
RenameAsync(string, ShareFileRenameOptions, CancellationToken)
Renames a file. This API does not support renaming a file from one share to another, or between storage accounts.
public virtual Task<Response<ShareFileClient>> RenameAsync(string destinationPath, ShareFileRenameOptions options = null, CancellationToken cancellationToken = default)
Parameters
destinationPath
stringThe destination path to rename the file to.
options
ShareFileRenameOptionsOptional parameters.
cancellationToken
CancellationTokenOptional CancellationToken to propagate notifications that the operation should be cancelled.
Returns
- Task<Response<ShareFileClient>>
A Azure.Response<> pointed at the newly renamed File.
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
SetHttpHeaders(long?, ShareFileHttpHeaders, FileSmbProperties, string, ShareFileRequestConditions, CancellationToken)
The SetHttpHeaders(long?, ShareFileHttpHeaders, FileSmbProperties, string, ShareFileRequestConditions, CancellationToken) operation sets system properties on the file.
For more information, see Set File Properties.
public virtual Response<ShareFileInfo> SetHttpHeaders(long? newSize = null, ShareFileHttpHeaders httpHeaders = null, FileSmbProperties smbProperties = null, string filePermission = null, ShareFileRequestConditions conditions = null, CancellationToken cancellationToken = default)
Parameters
newSize
long?Optional. Resizes a file to the specified size. If the specified byte value is less than the current size of the file, then all ranges above the specified byte value are cleared.
httpHeaders
ShareFileHttpHeadersOptional. The standard HTTP header system properties to set. If not specified, existing values will be cleared.
smbProperties
FileSmbPropertiesOptional SMB properties to set for the file.
filePermission
stringOptional file permission to set for the file.
conditions
ShareFileRequestConditionsOptional ShareFileRequestConditions to add conditions on creating the file.
cancellationToken
CancellationTokenOptional CancellationToken to propagate notifications that the operation should be cancelled.
Returns
- Response<ShareFileInfo>
A Azure.Response<> describing the state of the file.
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
SetHttpHeadersAsync(long?, ShareFileHttpHeaders, FileSmbProperties, string, ShareFileRequestConditions, CancellationToken)
The SetHttpHeadersAsync(long?, ShareFileHttpHeaders, FileSmbProperties, string, ShareFileRequestConditions, CancellationToken) operation sets system properties on the file.
For more information, see Set File Properties.
public virtual Task<Response<ShareFileInfo>> SetHttpHeadersAsync(long? newSize = null, ShareFileHttpHeaders httpHeaders = null, FileSmbProperties smbProperties = null, string filePermission = null, ShareFileRequestConditions conditions = null, CancellationToken cancellationToken = default)
Parameters
newSize
long?Optional. Resizes a file to the specified size. If the specified byte value is less than the current size of the file, then all ranges above the specified byte value are cleared.
httpHeaders
ShareFileHttpHeadersOptional. The standard HTTP header system properties to set. If not specified, existing values will be cleared.
smbProperties
FileSmbPropertiesOptional SMB properties to set for the file.
filePermission
stringOptional file permission to set for the file.
conditions
ShareFileRequestConditionsOptional ShareFileRequestConditions to add conditions on creating the file.
cancellationToken
CancellationTokenOptional CancellationToken to propagate notifications that the operation should be cancelled.
Returns
- Task<Response<ShareFileInfo>>
A Azure.Response<> describing the state of the file.
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
SetMetadata(IDictionary<string, string>, ShareFileRequestConditions, CancellationToken)
The SetMetadata(IDictionary<string, string>, ShareFileRequestConditions, CancellationToken) operation sets user-defined metadata for the specified file as one or more name-value pairs.
For more information, see Set File Metadata.
public virtual Response<ShareFileInfo> SetMetadata(IDictionary<string, string> metadata, ShareFileRequestConditions conditions = null, CancellationToken cancellationToken = default)
Parameters
metadata
IDictionary<string, string>Custom metadata to set for this file.
conditions
ShareFileRequestConditionsOptional ShareFileRequestConditions to add conditions on creating the file.
cancellationToken
CancellationTokenOptional CancellationToken to propagate notifications that the operation should be cancelled.
Returns
- Response<ShareFileInfo>
A Azure.Response<> describing the updated file.
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
SetMetadataAsync(IDictionary<string, string>, ShareFileRequestConditions, CancellationToken)
The SetMetadataAsync(IDictionary<string, string>, ShareFileRequestConditions, CancellationToken) operation sets user-defined metadata for the specified file as one or more name-value pairs.
For more information, see Set File Metadata.
public virtual Task<Response<ShareFileInfo>> SetMetadataAsync(IDictionary<string, string> metadata, ShareFileRequestConditions conditions = null, CancellationToken cancellationToken = default)
Parameters
metadata
IDictionary<string, string>Custom metadata to set for this file.
conditions
ShareFileRequestConditionsOptional ShareFileRequestConditions to add conditions on creating the file.
cancellationToken
CancellationTokenOptional CancellationToken to propagate notifications that the operation should be cancelled.
Returns
- Task<Response<ShareFileInfo>>
A Azure.Response<> describing the updated file.
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
StartCopy(Uri, ShareFileCopyOptions, CancellationToken)
Copies a blob or file to a destination file within the storage account.
For more information, see Copy File.
public virtual Response<ShareFileCopyInfo> StartCopy(Uri sourceUri, ShareFileCopyOptions options = null, CancellationToken cancellationToken = default)
Parameters
sourceUri
UriRequired. Specifies the URL of the source file or blob.
options
ShareFileCopyOptionsOptional parameters.
cancellationToken
CancellationTokenOptional CancellationToken to propagate notifications that the operation should be cancelled.
Returns
- Response<ShareFileCopyInfo>
A Azure.Response<> describing the state of the file copy.
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
StartCopyAsync(Uri, ShareFileCopyOptions, CancellationToken)
Copies a blob or file to a destination file within the storage account.
For more information, see Copy File.
public virtual Task<Response<ShareFileCopyInfo>> StartCopyAsync(Uri sourceUri, ShareFileCopyOptions options = null, CancellationToken cancellationToken = default)
Parameters
sourceUri
UriRequired. Specifies the URL of the source file or blob.
options
ShareFileCopyOptionsOptional parameters.
cancellationToken
CancellationTokenOptional CancellationToken to propagate notifications that the operation should be cancelled.
Returns
- Task<Response<ShareFileCopyInfo>>
A Azure.Response<> describing the state of the file copy.
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
Upload(Stream, ShareFileUploadOptions, CancellationToken)
The Upload(Stream, ShareFileUploadOptions, CancellationToken)
operation writes options.Stream.Stream
to a file.
For more information, see Put Range.
public virtual Response<ShareFileUploadInfo> Upload(Stream stream, ShareFileUploadOptions options = null, CancellationToken cancellationToken = default)
Parameters
stream
StreamContent stream to upload.
options
ShareFileUploadOptionsUpload options.
cancellationToken
CancellationTokenOptional CancellationToken to propagate notifications that the operation should be cancelled.
Returns
- Response<ShareFileUploadInfo>
A Azure.Response<> describing the state of the file.
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
UploadAsync(Stream, ShareFileUploadOptions, CancellationToken)
The UploadAsync(Stream, ShareFileUploadOptions, CancellationToken) operation writes
options.Stream.Stream
to a file.
For more information, see Put Range.
public virtual Task<Response<ShareFileUploadInfo>> UploadAsync(Stream stream, ShareFileUploadOptions options = null, CancellationToken cancellationToken = default)
Parameters
stream
StreamContent stream to upload.
options
ShareFileUploadOptionsUpload options.
cancellationToken
CancellationTokenOptional CancellationToken to propagate notifications that the operation should be cancelled.
Returns
- Task<Response<ShareFileUploadInfo>>
A Azure.Response<> describing the state of the file.
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
UploadRange(HttpRange, Stream, ShareFileUploadRangeOptions, CancellationToken)
The Azure.Storage.Files.Shares.ShareFileClient.UploadRange(Azure.HttpRange,System.IO.Stream,System.Byte[],System.IProgress{System.Int64},Azure.Storage.Files.Shares.Models.ShareFileRequestConditions,System.Threading.CancellationToken)
operation writes content
to a range
of a file.
For more information, see Put Range.
public virtual Response<ShareFileUploadInfo> UploadRange(HttpRange range, Stream content, ShareFileUploadRangeOptions options = null, CancellationToken cancellationToken = default)
Parameters
range
HttpRangeSpecifies the range of bytes to be written. Both the start and end of the range must be specified.
content
StreamA Stream containing the content of the range to upload.
options
ShareFileUploadRangeOptionsOptional parameters.
cancellationToken
CancellationTokenOptional CancellationToken to propagate notifications that the operation should be cancelled.
Returns
- Response<ShareFileUploadInfo>
A Azure.Response<> describing the state of the file.
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
UploadRangeAsync(HttpRange, Stream, ShareFileUploadRangeOptions, CancellationToken)
The Azure.Storage.Files.Shares.ShareFileClient.UploadRangeAsync(Azure.HttpRange,System.IO.Stream,System.Byte[],System.IProgress{System.Int64},Azure.Storage.Files.Shares.Models.ShareFileRequestConditions,System.Threading.CancellationToken)
operation writes content
to a range
of a file.
For more information, see Put Range.
public virtual Task<Response<ShareFileUploadInfo>> UploadRangeAsync(HttpRange range, Stream content, ShareFileUploadRangeOptions options = null, CancellationToken cancellationToken = default)
Parameters
range
HttpRangeSpecifies the range of bytes to be written. Both the start and end of the range must be specified.
content
StreamA Stream containing the content of the range to upload.
options
ShareFileUploadRangeOptionsOptional parameters.
cancellationToken
CancellationTokenOptional CancellationToken to propagate notifications that the operation should be cancelled.
Returns
- Task<Response<ShareFileUploadInfo>>
A Azure.Response<> describing the state of the file.
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
UploadRangeFromUri(Uri, HttpRange, HttpRange, ShareFileUploadRangeFromUriOptions, CancellationToken)
The UploadRangeFromUri(Uri, HttpRange, HttpRange, ShareFileUploadRangeFromUriOptions, CancellationToken) operation writes a range from an Azure File to another Azure file. This API is supported only for version 2019-02-02 and higher.
public virtual Response<ShareFileUploadInfo> UploadRangeFromUri(Uri sourceUri, HttpRange range, HttpRange sourceRange, ShareFileUploadRangeFromUriOptions options = null, CancellationToken cancellationToken = default)
Parameters
sourceUri
UriRequired. Specifies the URL of the source file, up to 2 KB in length. If source is an Azure blob or Azure file, it must either be public or must be authenticated via a shared access signature. If the source is public, no authentication is required to perform the operation.
range
HttpRangeSpecifies the range of bytes to be written. Both the start and end of the range must be specified.
sourceRange
HttpRangeSpecifies the range of bytes to be written from. Both the start and end of the range must be specified.
options
ShareFileUploadRangeFromUriOptionsOptional parameters. ShareFileUploadRangeFromUriOptions.
cancellationToken
CancellationTokenOptional CancellationToken to propagate notifications that the operation should be cancelled.
Returns
- Response<ShareFileUploadInfo>
A Azure.Response<> describing the state of the file.
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
UploadRangeFromUriAsync(Uri, HttpRange, HttpRange, ShareFileUploadRangeFromUriOptions, CancellationToken)
The Azure.Storage.Files.Shares.ShareFileClient.UploadRangeFromUriAsync(System.Uri,Azure.HttpRange,Azure.HttpRange,Azure.Storage.Files.Shares.Models.ShareFileRequestConditions,System.Threading.CancellationToken) operation writes a range from an Azure File to another Azure file. This API is supported only for version 2019-02-02 and higher.
public virtual Task<Response<ShareFileUploadInfo>> UploadRangeFromUriAsync(Uri sourceUri, HttpRange range, HttpRange sourceRange, ShareFileUploadRangeFromUriOptions options = null, CancellationToken cancellationToken = default)
Parameters
sourceUri
UriRequired. Specifies the URL of the source file, up to 2 KB in length. If source is an Azure blob or Azure file, it must either be public or must be authenticated via a shared access signature. If the source is public, no authentication is required to perform the operation.
range
HttpRangeSpecifies the range of bytes to be written. Both the start and end of the range must be specified.
sourceRange
HttpRangeSpecifies the range of bytes to be written from. Both the start and end of the range must be specified.
options
ShareFileUploadRangeFromUriOptionsOptional parameters. ShareFileUploadRangeFromUriOptions.
cancellationToken
CancellationTokenOptional CancellationToken to propagate notifications that the operation should be cancelled.
Returns
- Task<Response<ShareFileUploadInfo>>
A Azure.Response<> describing the state of the file.
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
WithSnapshot(string)
Initializes a new instance of the ShareFileClient
class with an identical Uri source but the specified
shareSnapshot
timestamp.
For more information, see Snapshot Share.
public virtual ShareFileClient WithSnapshot(string shareSnapshot)
Parameters
shareSnapshot
stringThe snapshot identifier.
Returns
- ShareFileClient
A new ShareFileClient instance.
Remarks
Pass null or empty string to remove the snapshot returning a URL to the base file.