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
Show file Open project: jornfilho/.net-Dev-Utils Class Usage Examples

Private Properties

Property Type Description

Public Methods

Method 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 method

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.
return bool

CreateFile() public method

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.
return bool

CreateFileTextWriter() public method

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.
return System.IO.TextWriter

CreateReadOnlyFile() public method

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.
return bool

DeleteFile() public method

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

DeleteFiles() public method

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

FileExists() public method

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

GetCountOfFilesInDirectory() public method

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

GetCountOfFilesInDirectoryAndSubdirectories() public method

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.
return int

IoFileUtils() public method

Base class constructor
public IoFileUtils ( ) : System
return System

IsFileReadOnly() public method

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.
return bool

ReadFileAsStream() public method

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.
return System.IO.FileStream

ReadFileAsString() public method

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

RemoveReadOnlyAttribute() public method

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