Show / Hide Table of Contents

Interface IStorageService

Defines a minimum implementation of a storage service.

Namespace: Talegen.Storage.Net.Core
Assembly: Talegen.Storage.Net.Core.dll
Syntax
public interface IStorageService

Properties

| Improve this Doc View Source

RootPath

Gets or sets the storage path for the instance of the storage service.

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

StorageId

Gets or sets the unique identity for the instance of the storage service.

Declaration
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
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
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.

| Improve this Doc View Source

DeleteDirectory(String, Boolean, Boolean)

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

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

Contains the name of the directory 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.

| Improve this Doc View Source

DeleteFile(String, Boolean)

This method is used to delete a file.

Declaration
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)

This method is used to delete a list of files.

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

Contains a list of file names that will be deleted.

System.Boolean deleteDirectory

Contains a value indicating whether the directory or directories the files are 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

DirectoryExists(String)

Contains a value indicating whether the folder already exists.

Declaration
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 Inspire application data directory.

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

Contains the sub-folder within the Inspire application data directory.

| Improve this Doc View Source

FileExists(String)

Contains a value indicating whether the file exists.

Declaration
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
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.

| Improve this Doc View Source

FindFiles(String, String, SearchOption)

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

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

Contains the sub-folder 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

MoveFile(String, String, Boolean)

This method is used to move a file.

Declaration
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
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
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
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
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
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
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.

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