Skip to content

File Extensions

Adrian Gabor edited this page Oct 31, 2021 · 1 revision

WriteToFileExt

Description
Write text to a file. If file exists it will overwrite.

Parameters
path (string)

Usage

string lorem = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.";
lorem.WriteToFileExt("c:\\temp\\lorem.txt");

Will write Lorem ipsum dolor sit amet, consectetur adipiscing elit. to a file located at c:\temp\lorem.txt. If the file already exists, it will overwrite the existing content.


WriteToGZippedFileExt

Description
Writes string to a compressed file with the extension gz.

Parameters
compressedFilePath (string)

Usage

string lorem = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.";
lorem.WriteToGZippedFileExt("c:\\temp\\lorem.txt");

Will compress the string lorem and write to a file located at c:\temp\lorem.txt. If the file already exists, it will overwrite the existing content.


ReadFromGZippedFileExt

Description
Reads a GZipped compressed file and returns the content as a decompressed string.

Parameters
None

Usage

string path = "c:\\temp\\lorem.gz";
string decompressedString = path.ReadFromGZippedFileExt();

Will read a file located at c:\temp\lorem.txt and decompress the contents to a string called decompressedString. If file does not exist, will throw a FileNotFoundException exception.


AppendToFileExt

Description
Append Text to a file or creates new file.

Parameters
path (string)

Usage

string lorem = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.";
lorem.AppendToFileExt("c:\\temp\\lorem.txt");

Will write Lorem ipsum dolor sit amet, consectetur adipiscing elit. to a file located at c:\temp\lorem.txt. If the file already exists, it will add the new text to whatever is already in the file. If the file doesn't exist, it will create it and add the new text.

Clone this wiki locally