Table of Contents

Class FileUtils

Namespace
Alternet.UI
Assembly
Alternet.UI.Common.dll

Contains static methods related to files.

public static class FileUtils
Inheritance
FileUtils

Fields

FileSizeEB

The "EB" (exabyte) unit string used in file size formatting.

FileSizeFormat

Specifies the format string used to display file sizes, where the first placeholder represents the size value and the second represents the unit.

FileSizeGB

The "GB" (gigabyte) unit string used in file size formatting.

FileSizeKB

The "KB" (kilobyte) unit string used in file size formatting.

FileSizeMB

The "MB" (megabyte) unit string used in file size formatting.

FileSizePB

The "PB" (petabyte) unit string used in file size formatting.

FileSizeTB

The "TB" (terabyte) unit string used in file size formatting.

FileSizeUnits

Gets an array of strings representing the units used to express file sizes, ranging from bytes to exabytes. Do not change number of elements and their order, because they are used in SizeToExplorerString(long?, IFormatProvider?) method.

Methods

CreateFilePath(string)

Gets directory name of the specified file path and creates that directory if it is not exists.

CreateFilePathSafe(string)

Creates the directory for the specified file path if it does not already exist. This method is a safe version of CreateFilePath(string) that catches exceptions.

DeleteBinObjFiles(string)

Deletes all files in the 'bin' and 'obj' subfolders of the specified solution folder.

DeleteIfExists(string)

Deletes the specified file if it exists.

DeleteIfExistsSafe(string)

Deletes the specified file if it exists in a safe manner.

ExistingDirOrNull(string?)

Returns path if such directory exists; otherwise returns Null.

ExistsOnPathUsingWhere(string, string?)

Checks whether executable with the specified name exists on path. Uses 'where' or similar command.

FindFileRecursiveInAppFolder(string, string?)

Returns the full file name that match a search pattern in the application folder. Searches in all subdirectories.

FindFirstFile(string, string, SearchOption)

Returns the full file name that match a search pattern in a specified path, and optionally searches subdirectories.

GetFullPathUsingWhere(string, string?)

Finds path to executable by it's name using 'where' or similar command.

HasFiles(string, string)

Gets whether the specified folder has files with the given mask.

RealFileHasSameCase(string)

Gets whether the specified file name has the same char case as file on disk.

SizeToExplorerString(long?, IFormatProvider?)

Returns the text representation of a file size in the style used by Windows File Explorer, with localizable unit strings.

StringFromFile(string, Encoding?)

Reads string from the file using the specified encoding.

StringToFile(string, string, Encoding?)

Saves string to file. If file with such name already exists, it is deleted before saving the string.

StringToFileIfChanged(string, string, Encoding?)

Saves string to the specified file only if its contents is different from the saved string.