ShareFileClient Class

Definition

The ShareFileClient allows you to manipulate Azure Storage files.

public class ShareFileClient
type ShareFileClient = class
Public Class ShareFileClient
Inheritance
ShareFileClient

Constructors

ShareFileClient()

Initializes a new instance of the ShareFileClient class for mocking.

ShareFileClient(String, String, String)

Initializes a new instance of the ShareFileClient class.

ShareFileClient(String, String, String, ShareClientOptions)

Initializes a new instance of the ShareFileClient class.

ShareFileClient(Uri, AzureSasCredential, ShareClientOptions)

Initializes a new instance of the ShareFileClient class.

ShareFileClient(Uri, ShareClientOptions)

Initializes a new instance of the ShareFileClient class.

ShareFileClient(Uri, StorageSharedKeyCredential, ShareClientOptions)

Initializes a new instance of the ShareFileClient class.

ShareFileClient(Uri, TokenCredential, ShareClientOptions)

Initializes a new instance of the ShareFileClient class.

Note that ShareTokenIntent is currently required for token authentication.

Properties

AccountName

Gets the Storage account name corresponding to the file client.

CanGenerateSasUri

Determines whether the client is able to generate a SAS. If the client is authenticated with a StorageSharedKeyCredential.

Name

Gets the name of the file.

Path

Gets the path of the file.

ShareName

Gets the share name corresponding to the file client.

Uri

Gets the directory's primary Uri endpoint.

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.

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.

ClearRange(HttpRange, ShareFileRequestConditions, CancellationToken)

The ClearRange(HttpRange, ShareFileRequestConditions, CancellationToken) operation clears the range of a file.

For more information, see Put Range.

ClearRangeAsync(HttpRange, ShareFileRequestConditions, CancellationToken)

The ClearRangeAsync(HttpRange, ShareFileRequestConditions, CancellationToken) operation clears the range of a file.

For more information, see Put Range.

Create(Int64, ShareFileHttpHeaders, IDictionary<String,String>, FileSmbProperties, String, ShareFileRequestConditions, CancellationToken)

Creates a new file or replaces an existing file.

For more information, see Create File.

CreateAsync(Int64, ShareFileHttpHeaders, IDictionary<String,String>, FileSmbProperties, String, ShareFileRequestConditions, CancellationToken)

Creates a new file or replaces an existing file.

For more information, see Create File.

Delete(ShareFileRequestConditions, CancellationToken)

The Delete(ShareFileRequestConditions, CancellationToken) operation immediately removes the file from the storage account.

For more information, see Delete File.

DeleteAsync(ShareFileRequestConditions, CancellationToken)

The DeleteAsync(ShareFileRequestConditions, CancellationToken) operation immediately removes the file from the storage account.

For more information, see Delete File.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

GetCopyAuthorizationHeaderAsync(ShareFileClient, CancellationToken)

Get a ShareFileClient's HttpAuthorization for passing the authorization when performing service to service copy where OAuth is necessary to authenticate the source.

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.

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.

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.

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.

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.

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.

GetRangeList(ShareFileGetRangeListOptions, CancellationToken)

Returns the list of valid ranges for a file.

For more information, see List Ranges.

GetRangeListAsync(ShareFileGetRangeListOptions, CancellationToken)

Returns the list of valid ranges for a file.

For more information, see List Ranges.

GetRangeListDiff(ShareFileGetRangeListDiffOptions, CancellationToken)

Returns the list of ranges that have changed in the file since previousSnapshot was taken.

For more information, see List Ranges.

GetRangeListDiffAsync(ShareFileGetRangeListDiffOptions, CancellationToken)

Returns the list of ranges that have changed in the file since previousSnapshot was taken.

For more information, see List Ranges.

OpenRead(ShareFileOpenReadOptions, CancellationToken)

Opens a stream for reading from the file. The stream will only download the file as the stream is read from.

OpenReadAsync(ShareFileOpenReadOptions, CancellationToken)

Opens a stream for reading from the file. The stream will only download the file as the stream is read from.

OpenWrite(Boolean, Int64, ShareFileOpenWriteOptions, CancellationToken)

Opens a stream for writing to the file.

OpenWriteAsync(Boolean, Int64, ShareFileOpenWriteOptions, CancellationToken)

Opens a stream for writing to the file.

Rename(String, ShareFileRenameOptions, CancellationToken)

Renames a file. This API does not support renaming a file from one share to another, or between storage accounts.

RenameAsync(String, ShareFileRenameOptions, CancellationToken)

Renames a file. This API does not support renaming a file from one share to another, or between storage accounts.

SetHttpHeaders(Nullable<Int64>, ShareFileHttpHeaders, FileSmbProperties, String, ShareFileRequestConditions, CancellationToken)

The SetHttpHeaders(Nullable<Int64>, ShareFileHttpHeaders, FileSmbProperties, String, ShareFileRequestConditions, CancellationToken) operation sets system properties on the file.

For more information, see Set File Properties.

SetHttpHeadersAsync(Nullable<Int64>, ShareFileHttpHeaders, FileSmbProperties, String, ShareFileRequestConditions, CancellationToken)

The SetHttpHeadersAsync(Nullable<Int64>, ShareFileHttpHeaders, FileSmbProperties, String, ShareFileRequestConditions, CancellationToken) operation sets system properties on the file.

For more information, see Set File Properties.

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.

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.

StartCopy(Uri, ShareFileCopyOptions, CancellationToken)

Copies a blob or file to a destination file within the storage account.

For more information, see Copy File.

StartCopyAsync(Uri, ShareFileCopyOptions, CancellationToken)

Copies a blob or file to a destination file within the storage account.

For more information, see Copy File.

Upload(Stream, ShareFileUploadOptions, CancellationToken)

The Upload(Stream, ShareFileUploadOptions, CancellationToken) operation writes options.Stream.Stream to a file.

For more information, see Put Range.

UploadAsync(Stream, ShareFileUploadOptions, CancellationToken)

The UploadAsync(Stream, ShareFileUploadOptions, CancellationToken) operation writes options.Stream.Stream to a file.

For more information, see Put Range.

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.

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.

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.

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.

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.

Extension Methods

GetShareLeaseClient(ShareFileClient, String)

Initializes a new instance of the ShareLeaseClient class.

GetParentShareClient(ShareFileClient)

Create a new ShareClient that pointing to this ShareFileClient's parent container. The new ShareClient uses the same request policy pipeline as the ShareFileClient.

GetParentShareDirectoryClient(ShareFileClient)

Create a new ShareDirectoryClient that pointing to this ShareFileClient's parent container. The new ShareDirectoryClient uses the same request policy pipeline as the ShareFileClient.

Applies to