C# Class 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

Inheritance: IIoFileUtils
Afficher le fichier Open project: jornfilho/.net-Dev-Utils Class Usage Examples

Private Properties

Свойство Type Description

Méthodes publiques

Méthode Description
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.

Method Details

CopyFile() public méthode

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.
Résultat bool

CreateFile() public méthode

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.
Résultat bool

CreateFileTextWriter() public méthode

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.
Résultat System.IO.TextWriter

CreateReadOnlyFile() public méthode

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.
Résultat bool

DeleteFile() public méthode

Deletes the specified file from the file system.
public DeleteFile ( string path ) : bool
path string The path to the file.
Résultat bool

DeleteFiles() public méthode

Deletes all files in the specified directory.
public DeleteFiles ( string path ) : int
path string The path to the directory.
Résultat int

FileExists() public méthode

Gets a value indicating if the specified file exists.
public FileExists ( string path ) : bool
path string The path to the file.
Résultat bool

GetCountOfFilesInDirectory() public méthode

Gets a count indicating the number of files in the specified directory.
public GetCountOfFilesInDirectory ( string path ) : int
path string The path to the directory.
Résultat int

GetCountOfFilesInDirectoryAndSubdirectories() public méthode

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.
Résultat int

IoFileUtils() public méthode

Base class constructor
public IoFileUtils ( ) : System
Résultat System

IsFileReadOnly() public méthode

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.
Résultat bool

ReadFileAsStream() public méthode

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.
Résultat System.IO.FileStream

ReadFileAsString() public méthode

Reads and returns the contents of the specified file.
public ReadFileAsString ( string path ) : string
path string The path to the file.
Résultat string

RemoveReadOnlyAttribute() public méthode

Remove read only attribute from file.
public RemoveReadOnlyAttribute ( string path ) : bool
path string The path to the file to remove read only attribute.
Résultat bool