Show / Hide Table of Contents

Class AzureBlobStorageService

This class implements the storage interface for implementing file IO with the Azure Blob File Shares.

Inheritance
System.Object
AzureBlobStorageService
Implements
IStorageService
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Talegen.Storage.Net.AzureBlobs
Assembly: Talegen.Storage.Net.AzureBlobs.dll
Syntax
public class AzureBlobStorageService : IStorageService

Constructors

| Improve this Doc View Source

AzureBlobStorageService(String, String, Boolean)

Initializes a new instance of the AzureBlobStorageService class.

Declaration
public AzureBlobStorageService(string connectionString, string accountName, bool uniqueWorkspace = false)
Parameters
Type Name Description
System.String connectionString

The connection string.

System.String accountName

Name of the account.

System.Boolean uniqueWorkspace

Contains a value indicating whether the storage service shall use a unique workspace sub-folder.

| Improve this Doc View Source

AzureBlobStorageService(Uri, String, String, Boolean)

Initializes a new instance of the AzureBlobStorageService class.

Declaration
public AzureBlobStorageService(Uri blobEndpointUri, string accountName, string accountKey, bool uniqueWorkspace = false)
Parameters
Type Name Description
System.Uri blobEndpointUri

The BLOB endpoint URI.

System.String accountName

Name of the account.

System.String accountKey

The account key.

System.Boolean uniqueWorkspace

Contains a value indicating whether the storage service shall use a unique workspace sub-folder.

| Improve this Doc View Source

AzureBlobStorageService(AzureBlobStorageContext)

Initializes a new instance of the AzureBlobStorageService class.

Declaration
public AzureBlobStorageService(AzureBlobStorageContext storageContext)
Parameters
Type Name Description
AzureBlobStorageContext storageContext

Contains an implementation of the storage context.

Properties

| Improve this Doc View Source

RootPath

Gets or sets the root folder path for this service instance.

Declaration
public string RootPath { get; set; }
Property Value
Type Description
System.String
| Improve this Doc View Source

StorageId

Gets or sets the storage identity for this service instance.

Declaration
public string StorageId { get; }
Property Value
Type Description
System.String

Methods

| Improve this Doc View Source

CopyFile(String, String, Boolean)

This method is used to copy a file.

Declaration
public void CopyFile(string sourceFilePath, string targetFilePath, bool overwrite = true)
Parameters
Type Name Description
System.String sourceFilePath

Contains a the path to the file that will be copied.

System.String targetFilePath

Contains the path to the target where the file is to be copied.

System.Boolean overwrite

Contains a value indicating if the target should be overwritten if it already exists. Default is true.

| Improve this Doc View Source

CreateDirectory(String, Boolean)

This method is used to create a temporary directory within the Inspire application path.

Declaration
public string CreateDirectory(string subFolderName, bool silentExists = false)
Parameters
Type Name Description
System.String subFolderName

Contains a sub-folder that will be included in the working directory path.

System.Boolean silentExists

Contains a value indicating whether the method is silently return successfully if the folder path already exists.

Returns
Type Description
System.String

Returns the name of the directory that was created.

Exceptions
Type Condition
StorageException

This exception is thrown if the directory is unable to be created.

| Improve this Doc View Source

DeleteDirectory(String, Boolean, Boolean)

This method is used to delete a sub-folder directory and all of its files.

Declaration
public void DeleteDirectory(string subFolderName, bool recursive = true, bool silentNoExist = true)
Parameters
Type Name Description
System.String subFolderName

Contains the sub-folder name of the directory off the root working folder that will be deleted.

System.Boolean recursive

Delete all contents within the folder.

System.Boolean silentNoExist

Contains a value indicating whether an exception is thrown if the target folder does not exist. Default is true; no exception is thrown if the folder does not exist.

Exceptions
Type Condition
StorageException

This exception is thrown if the directory is unable to be deleted.

| Improve this Doc View Source

DeleteFile(String, Boolean)

This method is used to delete a file.

Declaration
public void DeleteFile(string filePath, bool deleteDirectory = false)
Parameters
Type Name Description
System.String filePath

Contains a the path to the file that will be deleted.

System.Boolean deleteDirectory

Contains a value indicating whether the directory the file is within will be deleted. This will only occur if no other files remain in the directory after the list of files have been deleted.

| Improve this Doc View Source

DeleteFiles(List<String>, Boolean)

Deletes the files.

Declaration
public void DeleteFiles(List<string> filePathNames, bool deleteFolders = false)
Parameters
Type Name Description
System.Collections.Generic.List<System.String> filePathNames

The file path names.

System.Boolean deleteFolders

if set to true [delete folders].

Exceptions
Type Condition
System.NotImplementedException
| Improve this Doc View Source

DirectoryExists(String)

Contains a value indicating whether the folder already exists.

Declaration
public bool DirectoryExists(string subFolderName)
Parameters
Type Name Description
System.String subFolderName

Contains the sub-folder name excluding the root folder path.

Returns
Type Description
System.Boolean

Returns a value indicating whether the directory exists.

| Improve this Doc View Source

EmptyDirectory(String)

This method is used to delete all directories and files inside of a sub-folder within the specified workspace root path, however the folder is left in place empty.

Declaration
public void EmptyDirectory(string subFolderName)
Parameters
Type Name Description
System.String subFolderName

Contains the sub-folder within the within the specified workspace root path to empty.

| Improve this Doc View Source

FileExists(String)

Contains a value indicating whether the file exists.

Declaration
public bool FileExists(string filePath)
Parameters
Type Name Description
System.String filePath

Contains the sub-folder path and file name excluding the root folder path to determine if exists.

Returns
Type Description
System.Boolean

Returns a value indicating whether the file exists.

| Improve this Doc View Source

FileHash(String)

This method is used to create a hash of the file contents.

Declaration
public string FileHash(string filePath)
Parameters
Type Name Description
System.String filePath

The path to the file.

Returns
Type Description
System.String

Returns a hash of the file contents.

Exceptions
Type Condition
System.NotImplementedException
| Improve this Doc View Source

FindFiles(String, String, SearchOption)

This method is used to get the files from a directory.

Declaration
public List<string> FindFiles(string subFolderName, string searchPattern = "*.*", SearchOption searchOption = SearchOption.AllDirectories)
Parameters
Type Name Description
System.String subFolderName

Contains the directory name to get the files.

System.String searchPattern

Contains an optional file name search pattern. If not specified, . is used.

System.IO.SearchOption searchOption

Contains search options. If not specified, all sub-folders are searched for the file pattern.

Returns
Type Description
System.Collections.Generic.List<System.String>

Returns a list of files in the directory path.

| Improve this Doc View Source

Initialize(AzureBlobStorageContext)

This method is used to initialize a storage service with the specified settings provided within the IStorageContext object.

Declaration
public void Initialize(AzureBlobStorageContext storageContext)
Parameters
Type Name Description
AzureBlobStorageContext storageContext

Contains the settings used to initialize the storage service.

| Improve this Doc View Source

MoveFile(String, String, Boolean)

This method is used to move a file.

Declaration
public void MoveFile(string sourceFilePath, string targetFilePath, bool overwrite = true)
Parameters
Type Name Description
System.String sourceFilePath

Contains a the path to the file that will be moved.

System.String targetFilePath

Contains the path to the target where the file is to be moved.

System.Boolean overwrite

Contains a value indicating if the target should be overwritten if it already exists. Default is true.

| Improve this Doc View Source

ReadBinaryFile(String)

This method is used to read all the bytes from a binary file.

Declaration
public byte[] ReadBinaryFile(string path)
Parameters
Type Name Description
System.String path

Contains the path to the file to load and return.

Returns
Type Description
System.Byte[]

Returns a byte array containing the binary bytes of the target file.

| Improve this Doc View Source

ReadBinaryFile(String, Stream)

This method is used to read all the bytes from a binary file to a provided stream.

Declaration
public void ReadBinaryFile(string path, Stream outputStream)
Parameters
Type Name Description
System.String path

Contains the path to the file to load into the stream.

System.IO.Stream outputStream

The stream to write the file to.

| Improve this Doc View Source

ReadTextFile(String, Encoding)

This method is used to read all the bytes from a text file.

Declaration
public string ReadTextFile(string path, Encoding encoding = null)
Parameters
Type Name Description
System.String path

Contains the path to the file to load and return.

System.Text.Encoding encoding

Contains the text encoding type. If none is specified, Encoding.Default is used.

Returns
Type Description
System.String

Returns a string containing the content of the target file.

| Improve this Doc View Source

WriteBinaryFile(String, Byte[])

This method is used to write content to the specified path.

Declaration
public bool WriteBinaryFile(string path, byte[] content)
Parameters
Type Name Description
System.String path

Contains the fully qualified path, including file name, to the location in which the binary content shall be written.

System.Byte[] content

Contains a byte array of the content to be written.

Returns
Type Description
System.Boolean

Returns a value indicating whether the write was successful.

| Improve this Doc View Source

WriteBinaryFile(String, Stream)

This method is used to write content to the specified path.

Declaration
public bool WriteBinaryFile(string path, Stream inputStream)
Parameters
Type Name Description
System.String path

Contains the fully qualified path, including file name, to the location in which the binary content shall be written.

System.IO.Stream inputStream

Contains a stream of the content to be written.

Returns
Type Description
System.Boolean

Returns a value indicating whether the write was successful.

| Improve this Doc View Source

WriteTextFile(String, String, Encoding)

This method is used to write content to the specified path.

Declaration
public bool WriteTextFile(string path, string content, Encoding encoding = null)
Parameters
Type Name Description
System.String path

Contains the fully qualified path, including file name, to the location in which the text content shall be written.

System.String content

Contains a string of the content to be written.

System.Text.Encoding encoding

Contains the text file encoding. If none specified, Encoding.Default is used.

Returns
Type Description
System.Boolean

Returns a value indicating whether the write was successful.

Implements

IStorageService
  • Improve this Doc
  • View Source
In This Article
Back to top Copyright (c) Talegen, LLC. All rights reserved.