Static Public Member Functions

static ASPOSECPP_SHARED_API void AppendAllLines (const String &path, const SharedPtr< Collections::Generic::IEnumerable< String >> &contents, const EncodingPtr &encoding=Text::Encoding::get_UTF8Unmarked())
 
static ASPOSECPP_SHARED_API void AppendAllText (const String &path, const String &contents, const EncodingPtr &encoding=Text::Encoding::get_UTF8Unmarked())
 
static ASPOSECPP_SHARED_API StreamWriterPtr AppendText (const String &path)
 
static ASPOSECPP_SHARED_API void Copy (const String &sourceFileName, const String &destFileName, bool overwrite=false)
 
static ASPOSECPP_SHARED_API FileStreamPtr Create (const String &path, int32_t bufferSize=DefaultBufferSize, FileOptions options=FileOptions::None)
 
static ASPOSECPP_SHARED_API StreamWriterPtr CreateText (const String &path)
 
static ASPOSECPP_SHARED_API void Decrypt (const String &path)
 
static ASPOSECPP_SHARED_API void Delete (const String &path)
 
static ASPOSECPP_SHARED_API void Encrypt (const String &path)
 
static ASPOSECPP_SHARED_API bool Exists (const String &path)
 
static ASPOSECPP_SHARED_API FileAttributes GetAttributes (const String &path)
 
static ASPOSECPP_SHARED_API DateTime GetCreationTime (const String &path)
 
static ASPOSECPP_SHARED_API DateTime GetCreationTimeUtc (const String &path)
 
static ASPOSECPP_SHARED_API DateTime GetLastAccessTime (const String &path)
 
static ASPOSECPP_SHARED_API DateTime GetLastAccessTimeUtc (const String &path)
 
static ASPOSECPP_SHARED_API DateTime GetLastWriteTime (const String &path)
 
static ASPOSECPP_SHARED_API DateTime GetLastWriteTimeUtc (const String &path)
 
static ASPOSECPP_SHARED_API void Move (const String &sourceFileName, const String &destFileName)
 
static ASPOSECPP_SHARED_API FileStreamPtr Open (const String &path, FileMode mode)
 
static ASPOSECPP_SHARED_API FileStreamPtr Open (const String &path, FileMode mode, FileAccess access, FileShare share=FileShare::None)
 
static ASPOSECPP_SHARED_API FileStreamPtr OpenRead (const String &path)
 
static ASPOSECPP_SHARED_API StreamReaderPtr OpenText (const String &path, const EncodingPtr &encoding=Text::Encoding::get_UTF8Unmarked())
 
static ASPOSECPP_SHARED_API FileStreamPtr OpenWrite (const String &path)
 
static ASPOSECPP_SHARED_API ArrayPtr< uint8_t > ReadAllBytes (const String &path)
 
static ASPOSECPP_SHARED_API ArrayPtr< StringReadAllLines (const String &path, const EncodingPtr &encoding=Text::Encoding::get_UTF8())
 
static ASPOSECPP_SHARED_API String ReadAllText (const String &path, const EncodingPtr &encoding=Text::Encoding::get_UTF8())
 
static ASPOSECPP_SHARED_API SharedPtr< Collections::Generic::IEnumerable< String > > ReadLines (const String &path, const EncodingPtr &encoding=Text::Encoding::get_UTF8())
 
static ASPOSECPP_SHARED_API void Replace (const String &sourceFileName, const String &destinationFileName, const String &destinationBackupFileName, bool ignoreMetadataErrors=1)
 
static ASPOSECPP_SHARED_API void SetAttributes (const String &path, FileAttributes fileAttributes)
 
static ASPOSECPP_SHARED_API void SetCreationTime (const String &path, DateTime creationTime)
 
static ASPOSECPP_SHARED_API void SetCreationTimeUtc (const String &path, DateTime creationTimeUtc)
 
static ASPOSECPP_SHARED_API void SetLastWriteTime (const String &path, DateTime lastWriteTime)
 
static ASPOSECPP_SHARED_API void SetLastWriteTimeUtc (const String &path, DateTime lastWriteTimeUtc)
 
static ASPOSECPP_SHARED_API void SetLastAccessTime (const String &path, DateTime lastWriteTime)
 
static ASPOSECPP_SHARED_API void SetLastAccessTimeUtc (const String &path, DateTime lastWriteTimeUtc)
 
static ASPOSECPP_SHARED_API void WriteAllBytes (const String &path, const ArrayPtr< uint8_t > &bytes)
 
static ASPOSECPP_SHARED_API void WriteAllLines (const String &path, const SharedPtr< Collections::Generic::IEnumerable< String >> &contents, const EncodingPtr &encoding=Text::Encoding::get_UTF8Unmarked())
 
static ASPOSECPP_SHARED_API void WriteAllLines (const String &path, const ArrayPtr< String > &contents, const EncodingPtr &encoding=Text::Encoding::get_UTF8Unmarked())
 
static ASPOSECPP_SHARED_API void WriteAllText (const String &path, const String &contents, const EncodingPtr &encoding=Text::Encoding::get_UTF8Unmarked())
 

Static Public Attributes

static const int32_t ASPOSECPP_SHARED_API DefaultBufferSize
 Default value of the number of bytes buffered during reading from and writing to a file. More...
 

Detailed Description

Provides methods for manipulating files. This is a static type with no instance services. You should never create instances of it by any means.

Member Function Documentation

◆ AppendAllLines()

static ASPOSECPP_SHARED_API void System::IO::File::AppendAllLines ( const String path,
const SharedPtr< Collections::Generic::IEnumerable< String >> &  contents,
const EncodingPtr encoding = Text::Encoding::get_UTF8Unmarked() 
)
static

Appends strings from the specified collection of strings to the specified file using the specified encoding by writing each string in a new line. If the specified file does not exist, it is created. The file is closed after writing all strings.

Parameters
pathThe path of the file to append the strings to
contentsThe strings to write to the file
encodingThe character encoding to use

◆ AppendAllText()

static ASPOSECPP_SHARED_API void System::IO::File::AppendAllText ( const String path,
const String contents,
const EncodingPtr encoding = Text::Encoding::get_UTF8Unmarked() 
)
static

Appends the specified string to the specified file using the specified encoding.

Parameters
pathThe path of the file to append the string to
contentsThe string to write to the file
encodingThe character encoding to use

◆ AppendText()

static ASPOSECPP_SHARED_API StreamWriterPtr System::IO::File::AppendText ( const String path)
static

Creates a StreamWriter object that appends text to the specified file using UTF-8 encoding. If the specified file does not exist, it is created.

Parameters
pathThe path of the file to open or create
Returns
A shared pointer to the created StreamWriter object associated with the specified file

◆ Copy()

static ASPOSECPP_SHARED_API void System::IO::File::Copy ( const String sourceFileName,
const String destFileName,
bool  overwrite = false 
)
static

Copies the specified file to the specified location. If the destination file already exists, a parameter specifies if it should be overwritten.

Parameters
sourceFileNameA path of the file to copy
destFileNameA path of the new location of the file to copy
overwriteTrue if the existing destination file should be overwritten, false if copying should fail if the destination file already exists

◆ Create()

static ASPOSECPP_SHARED_API FileStreamPtr System::IO::File::Create ( const String path,
int32_t  bufferSize = DefaultBufferSize,
FileOptions  options = FileOptions::None 
)
static

Creates a new file (or overwrites existing) and opens it for reading and writing access using the specified buffer size and options.

Parameters
pathThe path of the file to create or overwrite
bufferSizeThe number of bytes buffered when reading from and writing to the file
optionsSpecifies how to create or overwrite the file
Returns
A shared pointer to the FileStream object associated with the specified file

◆ CreateText()

static ASPOSECPP_SHARED_API StreamWriterPtr System::IO::File::CreateText ( const String path)
static

Creates a new or opens existing file for writing UTF-8 encoded text.

Parameters
pathThe path of the file to create or open
Returns
A shared pointer to the StreamWriter object associated with the specified file

◆ Decrypt()

static ASPOSECPP_SHARED_API void System::IO::File::Decrypt ( const String path)
static

NOT IMPLEMENTED.

Exceptions
NotImplementedExceptionAlways

◆ Delete()

static ASPOSECPP_SHARED_API void System::IO::File::Delete ( const String path)
static

Deletes the specified file or directory.

Parameters
pathThe path of the file or directory to delete

◆ Encrypt()

static ASPOSECPP_SHARED_API void System::IO::File::Encrypt ( const String path)
static

NOT IMPLEMENTED.

Exceptions
NotImplementedExceptionAlways

◆ Exists()

static ASPOSECPP_SHARED_API bool System::IO::File::Exists ( const String path)
static

Determines if the specified path references an existing file.

Parameters
pathThe path to test
Returns
True if the path references an existing file, otherwise - false

◆ GetAttributes()

static ASPOSECPP_SHARED_API FileAttributes System::IO::File::GetAttributes ( const String path)
static

Returns the attributes of the specified entity.

Parameters
pathThe path of the entity whose attributes to return
Returns
The attributes of the entity referenced by path

◆ GetCreationTime()

static ASPOSECPP_SHARED_API DateTime System::IO::File::GetCreationTime ( const String path)
static

Returns the creation time of the specified entity as local time.

Parameters
pathThe entity whose creating time to retrieve
Returns
A DateTime object representing the creation time of the specified entity as local time

◆ GetCreationTimeUtc()

static ASPOSECPP_SHARED_API DateTime System::IO::File::GetCreationTimeUtc ( const String path)
static

Returns the creation time of the specified entity as UTC time.

Parameters
pathThe entity whose creating time to retrieve
Returns
A DateTime object representing the creation time of the specified entity as UTC time

◆ GetLastAccessTime()

static ASPOSECPP_SHARED_API DateTime System::IO::File::GetLastAccessTime ( const String path)
static

Returns the last access time of the specified entity as local time.

Parameters
pathThe entity whose last access time to retrieve
Returns
A DateTime object representing the last access time of the specified entity as local time

◆ GetLastAccessTimeUtc()

static ASPOSECPP_SHARED_API DateTime System::IO::File::GetLastAccessTimeUtc ( const String path)
static

Returns the last access time of the specified entity as UTC time.

Parameters
pathThe entity whose last access time to retrieve
Returns
A DateTime object representing the last access time of the specified entity as UTC time

◆ GetLastWriteTime()

static ASPOSECPP_SHARED_API DateTime System::IO::File::GetLastWriteTime ( const String path)
static

Returns the last write time of the specified entity as local time.

Parameters
pathThe entity whose last write time to retrieve
Returns
A DateTime object representing the last write time of the specified entity as local time

◆ GetLastWriteTimeUtc()

static ASPOSECPP_SHARED_API DateTime System::IO::File::GetLastWriteTimeUtc ( const String path)
static

Returns the last write time of the specified entity as UTC time.

Parameters
pathThe entity whose last write time to retrieve
Returns
A DateTime object representing the last write time of the specified entity as UTC time

◆ Move()

static ASPOSECPP_SHARED_API void System::IO::File::Move ( const String sourceFileName,
const String destFileName 
)
static

Moves the specified file to the new location.

Parameters
sourceFileNameA file to move
destFileNameThe new location of a file referenced by sourceFileName

◆ Open() [1/2]

static ASPOSECPP_SHARED_API FileStreamPtr System::IO::File::Open ( const String path,
FileMode  mode 
)
static

Opens the specified file in the specified mode for reading and writing and with no sharing.

Parameters
pathThe path of the file to open
modeSpecifies the mode in which to open the file
Returns
A FileStream object associated with the opened file

◆ Open() [2/2]

static ASPOSECPP_SHARED_API FileStreamPtr System::IO::File::Open ( const String path,
FileMode  mode,
FileAccess  access,
FileShare  share = FileShare::None 
)
static

Opens the specified file in the specified mode, with the specified access type and sharing option.

Parameters
pathThe path of the file to open
modeSpecifies the mode in which to open the file
accessThe requested access type
shareThe type of access that other FileStream objects have to the opened file
Returns
A FileStream object associated with the opened file

◆ OpenRead()

static ASPOSECPP_SHARED_API FileStreamPtr System::IO::File::OpenRead ( const String path)
static

Opens the specified file for reading only, in 'Open' mode with shared access for reading.

Parameters
pathThe path of the file to open
Returns
A FileStream object associated with the opened file

◆ OpenText()

static ASPOSECPP_SHARED_API StreamReaderPtr System::IO::File::OpenText ( const String path,
const EncodingPtr encoding = Text::Encoding::get_UTF8Unmarked() 
)
static

Opens the specified existing file for reading text using UTF-8 encoding with no sharing.

Parameters
pathThe path of the file to open
encodingThe character encoding to use
Returns
A shared pointer to a StreamWriter object associated with the opened file

◆ OpenWrite()

static ASPOSECPP_SHARED_API FileStreamPtr System::IO::File::OpenWrite ( const String path)
static

Opens the specified file for writing only, in 'OpenOrCreate' mode with no sharing.

Parameters
pathThe path of the file to open
Returns
A FileStream object associated with the opened file

◆ ReadAllBytes()

static ASPOSECPP_SHARED_API ArrayPtr<uint8_t> System::IO::File::ReadAllBytes ( const String path)
static

Reads the content of the specified binary file to a byte array.

Parameters
pathThe path of the file to read
Returns
A byte array containing the content of the file

◆ ReadAllLines()

static ASPOSECPP_SHARED_API ArrayPtr<String> System::IO::File::ReadAllLines ( const String path,
const EncodingPtr encoding = Text::Encoding::get_UTF8() 
)
static

Reads the content of the specified text file line by line to an array of strings using the specified character encoding.

Parameters
pathThe path of the file to read
encodingThe character encoding to use
Returns
A string array each element of which represents a single line from the specified file

◆ ReadAllText()

static ASPOSECPP_SHARED_API String System::IO::File::ReadAllText ( const String path,
const EncodingPtr encoding = Text::Encoding::get_UTF8() 
)
static

Reads the content of the specified text file to a single String object using the specified character encoding.

Parameters
pathThe path of the file to read
encodingThe character encoding to use
Returns
A string containing the content of the specified file

◆ ReadLines()

static ASPOSECPP_SHARED_API SharedPtr<Collections::Generic::IEnumerable<String> > System::IO::File::ReadLines ( const String path,
const EncodingPtr encoding = Text::Encoding::get_UTF8() 
)
static

Reads the content of the specified text file line by line using the specified character encoding and returns enumerable collection of strings each of which represents a single line of the file's content.

Parameters
pathThe path of the file to read
encodingThe character encoding to use
Returns
An enumerable collection of strings representing the content of the specified file

◆ Replace()

static ASPOSECPP_SHARED_API void System::IO::File::Replace ( const String sourceFileName,
const String destinationFileName,
const String destinationBackupFileName,
bool  ignoreMetadataErrors = 1 
)
static

Replaces the contents of a one file with another and creates a backup of the replaced file.

Parameters
sourceFileNameA name of the file to replace with
destinationFileNameA name of the file to replace
destinationBackupFileNameA name of the backup file
ignoreMetadataErrorsSpecifies if the merge errors from the replaced file to the replacement file should be ignored (true) or not (false)

◆ SetAttributes()

static ASPOSECPP_SHARED_API void System::IO::File::SetAttributes ( const String path,
FileAttributes  fileAttributes 
)
static

Sets the specified attributes on the specified file.

Parameters
pathThe path of the file on which the attributes to be set
fileAttributesA bitwise combination of FileAttributes values representing the attributes to set

◆ SetCreationTime()

static ASPOSECPP_SHARED_API void System::IO::File::SetCreationTime ( const String path,
DateTime  creationTime 
)
static

NOT IMPLEMENTED.

Exceptions
NotImplementedExceptionAlways

◆ SetCreationTimeUtc()

static ASPOSECPP_SHARED_API void System::IO::File::SetCreationTimeUtc ( const String path,
DateTime  creationTimeUtc 
)
static

NOT IMPLEMENTED.

Exceptions
NotImplementedExceptionAlways

◆ SetLastAccessTime()

static ASPOSECPP_SHARED_API void System::IO::File::SetLastAccessTime ( const String path,
DateTime  lastWriteTime 
)
static

NOT IMPLEMENTED.

Exceptions
NotImplementedExceptionAlways

◆ SetLastAccessTimeUtc()

static ASPOSECPP_SHARED_API void System::IO::File::SetLastAccessTimeUtc ( const String path,
DateTime  lastWriteTimeUtc 
)
static

NOT IMPLEMENTED.

Exceptions
NotImplementedExceptionAlways

◆ SetLastWriteTime()

static ASPOSECPP_SHARED_API void System::IO::File::SetLastWriteTime ( const String path,
DateTime  lastWriteTime 
)
static

Sets the last write time of the specified entity as local time.

Parameters
pathThe entity whose last write time to set
lastWriteTimeA DateTime object representing the time to set as local time

◆ SetLastWriteTimeUtc()

static ASPOSECPP_SHARED_API void System::IO::File::SetLastWriteTimeUtc ( const String path,
DateTime  lastWriteTimeUtc 
)
static

Sets the last write time of the specified entity as UTC time.

Parameters
pathThe entity whose last write time to set
lastWriteTimeUtcA DateTime object representing the time to set as UTC time

◆ WriteAllBytes()

static ASPOSECPP_SHARED_API void System::IO::File::WriteAllBytes ( const String path,
const ArrayPtr< uint8_t > &  bytes 
)
static

Overwrites the specified binary file and writes the specified bytes to it.

Parameters
pathThe file to write to
bytesThe byte array containing the bytes to write to the specified file

◆ WriteAllLines() [1/2]

static ASPOSECPP_SHARED_API void System::IO::File::WriteAllLines ( const String path,
const SharedPtr< Collections::Generic::IEnumerable< String >> &  contents,
const EncodingPtr encoding = Text::Encoding::get_UTF8Unmarked() 
)
static

Creates a new text file or overwrites the existing one and writes all strings from the specified enumerable collection of strings to it, each string on a new line, using the specified encoding.

Parameters
pathThe file to create or overwrite
contentsAn enumerable collection of strings
encodingThe character encoding to use

◆ WriteAllLines() [2/2]

static ASPOSECPP_SHARED_API void System::IO::File::WriteAllLines ( const String path,
const ArrayPtr< String > &  contents,
const EncodingPtr encoding = Text::Encoding::get_UTF8Unmarked() 
)
static

Creates a new text file or overwrites the existing one and writes all strings from the specified array of strings to it, each string on a new line, using the specified encoding.

Parameters
pathThe file to create or overwrite
contentsA string array
encodingThe character encoding to use

◆ WriteAllText()

static ASPOSECPP_SHARED_API void System::IO::File::WriteAllText ( const String path,
const String contents,
const EncodingPtr encoding = Text::Encoding::get_UTF8Unmarked() 
)
static

Creates a new text file or overwrites the existing one and writes the content of the specified string to it using the specified encoding.

Parameters
pathThe file to create or overwrite
contentsA string array
encodingThe character encoding to use

Member Data Documentation

◆ DefaultBufferSize

const int32_t ASPOSECPP_SHARED_API System::IO::File::DefaultBufferSize
static

Default value of the number of bytes buffered during reading from and writing to a file.