C# Класс DevUtils.Io.IoFileUtils

The IoFileUtils type provides an implementation of the IIoFileUtils interface that provides utility methods for common I/O file operations.

Base project reference: https://github.com/cjaehnen/OpenLib.Utils

Наследование: IIoFileUtils
Показать файл Открыть проект Примеры использования класса

Private Properties

Свойство Тип Описание

Открытые методы

Метод Описание
CopyFile ( string sourcePath, string targetPath ) : bool

Copies the specified source file to the target file path.

CreateFile ( string path, string contents ) : bool

Writes the specified contents to the specified file.

CreateFileTextWriter ( string path ) : TextWriter

Creates a file text writer used to create file output.

This implementation returns a StreamWriter.

CreateReadOnlyFile ( string path, string contents ) : bool

Creates a read only file for the specified file or sets the file to read only if it already exists.

DeleteFile ( string path ) : bool

Deletes the specified file from the file system.

DeleteFiles ( string path ) : int

Deletes all files in the specified directory.

FileExists ( string path ) : bool

Gets a value indicating if the specified file exists.

GetCountOfFilesInDirectory ( string path ) : int

Gets a count indicating the number of files in the specified directory.

GetCountOfFilesInDirectoryAndSubdirectories ( string path ) : int

Gets a count indicating the number of files in the specified directory and subdirectories.

IoFileUtils ( ) : System

Base class constructor

IsFileReadOnly ( string path ) : bool

Gets a value indicating if the specified file is read only.

ReadFileAsStream ( string path ) : FileStream

Reads and returns the contents of the specified file as a file stream.

ReadFileAsString ( string path ) : string

Reads and returns the contents of the specified file.

RemoveReadOnlyAttribute ( string path ) : bool

Remove read only attribute from file.

Описание методов

CopyFile() публичный Метод

Copies the specified source file to the target file path.
public CopyFile ( string sourcePath, string targetPath ) : bool
sourcePath string The path to the source file.
targetPath string The path to the target file.
Результат bool

CreateFile() публичный Метод

Writes the specified contents to the specified file.
public CreateFile ( string path, string contents ) : bool
path string The path to the file.
contents string The contents of the file.
Результат bool

CreateFileTextWriter() публичный Метод

Creates a file text writer used to create file output.
This implementation returns a StreamWriter.
public CreateFileTextWriter ( string path ) : TextWriter
path string The path to the file.
Результат System.IO.TextWriter

CreateReadOnlyFile() публичный Метод

Creates a read only file for the specified file or sets the file to read only if it already exists.
public CreateReadOnlyFile ( string path, string contents ) : bool
path string The path to the file to set as read only.
contents string The contents of the file.
Результат bool

DeleteFile() публичный Метод

Deletes the specified file from the file system.
public DeleteFile ( string path ) : bool
path string The path to the file.
Результат bool

DeleteFiles() публичный Метод

Deletes all files in the specified directory.
public DeleteFiles ( string path ) : int
path string The path to the directory.
Результат int

FileExists() публичный Метод

Gets a value indicating if the specified file exists.
public FileExists ( string path ) : bool
path string The path to the file.
Результат bool

GetCountOfFilesInDirectory() публичный Метод

Gets a count indicating the number of files in the specified directory.
public GetCountOfFilesInDirectory ( string path ) : int
path string The path to the directory.
Результат int

GetCountOfFilesInDirectoryAndSubdirectories() публичный Метод

Gets a count indicating the number of files in the specified directory and subdirectories.
public GetCountOfFilesInDirectoryAndSubdirectories ( string path ) : int
path string The path to the directory.
Результат int

IoFileUtils() публичный Метод

Base class constructor
public IoFileUtils ( ) : System
Результат System

IsFileReadOnly() публичный Метод

Gets a value indicating if the specified file is read only.
public IsFileReadOnly ( string path ) : bool
path string The path to the file to determine if it is read only.
Результат bool

ReadFileAsStream() публичный Метод

Reads and returns the contents of the specified file as a file stream.
public ReadFileAsStream ( string path ) : FileStream
path string The path to the file.
Результат System.IO.FileStream

ReadFileAsString() публичный Метод

Reads and returns the contents of the specified file.
public ReadFileAsString ( string path ) : string
path string The path to the file.
Результат string

RemoveReadOnlyAttribute() публичный Метод

Remove read only attribute from file.
public RemoveReadOnlyAttribute ( string path ) : bool
path string The path to the file to remove read only attribute.
Результат bool