C# Class Oglr.Core.Disk

Represents a disk. A facade over the Path and File API's.
Inheritance: IDisk
Show file Open project: SteveDunn/oglr Class Usage Examples

Public Methods

Method Description
Combine ( string firstPart, string secondPart ) : string
CopyFolder ( string fromDirectory, string toDirectory ) : void

Copies the folder.

CreateDirectoryIfDoesNotExist ( string directoryPath ) : void
DeleteFileOrDirectory ( string path ) : void

Deletes the file or directory.

DeleteFilesOrDirectories ( IEnumerable paths ) : void

Deletes the files or directories.

FileExists ( string localPath ) : bool
FilenamesInDirectory ( string pathToFolder, string searchPattern, SearchOption searchOption ) : IEnumerable
FolderExists ( string pathToFolder ) : bool
GetChildDirectoriesRecursively ( string directory ) : IEnumerable

Builds a list containing all the files under a specific directory

GetDirectoryNameFromPath ( string path ) : string
GetEntityType ( string path ) : DiskEntity

Gets the type of the entity, for instance, Folder, File, etc.

GetFilesInDirectoryRecursively ( string directory ) : IEnumerable

Builds a list containing all the files under a specific directory

GetTempPath ( ) : string
IsFile ( string path ) : bool

Determines whether the specified path is a file.

IsFolder ( string path ) : bool

Determines whether the specified path is a folder.

IsSubfolder ( string parentPath, string childPath ) : bool
MakeRelativePath ( string fromPath, string toPath ) : string

Creates a relative path from one file or folder to another.

ReadAllText ( string path ) : string

Reads a text file from disk

SetFileReadOnly ( string filePath, bool isReadOnly ) : void

Toggles the Read-Only attribute on a file

WriteTextToFile ( string path, string fileContents ) : void

Writes a text file to disk

Private Methods

Method Description
areSameFolders ( DirectoryInfo left, DirectoryInfo right ) : bool
isDirectory ( string path ) : bool
isFileReadOnly ( string path ) : bool

Method Details

Combine() public method

public Combine ( string firstPart, string secondPart ) : string
firstPart string
secondPart string
return string

CopyFolder() public method

Copies the folder.
public CopyFolder ( string fromDirectory, string toDirectory ) : void
fromDirectory string From directory.
toDirectory string To directory.
return void

CreateDirectoryIfDoesNotExist() public method

public CreateDirectoryIfDoesNotExist ( string directoryPath ) : void
directoryPath string
return void

DeleteFileOrDirectory() public method

Deletes the file or directory.
public DeleteFileOrDirectory ( string path ) : void
path string The path to the file or directory.
return void

DeleteFilesOrDirectories() public method

Deletes the files or directories.
public DeleteFilesOrDirectories ( IEnumerable paths ) : void
paths IEnumerable The paths.
return void

FileExists() public method

public FileExists ( string localPath ) : bool
localPath string
return bool

FilenamesInDirectory() public method

public FilenamesInDirectory ( string pathToFolder, string searchPattern, SearchOption searchOption ) : IEnumerable
pathToFolder string
searchPattern string
searchOption SearchOption
return IEnumerable

FolderExists() public method

public FolderExists ( string pathToFolder ) : bool
pathToFolder string
return bool

GetChildDirectoriesRecursively() public method

Builds a list containing all the files under a specific directory
public GetChildDirectoriesRecursively ( string directory ) : IEnumerable
directory string The parent directory.
return IEnumerable

GetDirectoryNameFromPath() public method

public GetDirectoryNameFromPath ( string path ) : string
path string
return string

GetEntityType() public method

Gets the type of the entity, for instance, Folder, File, etc.
public GetEntityType ( string path ) : DiskEntity
path string The path to the item on disk.
return DiskEntity

GetFilesInDirectoryRecursively() public method

Builds a list containing all the files under a specific directory
public GetFilesInDirectoryRecursively ( string directory ) : IEnumerable
directory string The parent directory.
return IEnumerable

GetTempPath() public method

public GetTempPath ( ) : string
return string

IsFile() public method

Determines whether the specified path is a file.
public IsFile ( string path ) : bool
path string The path to the disk entity.
return bool

IsFolder() public method

Determines whether the specified path is a folder.
public IsFolder ( string path ) : bool
path string The path with which to see if it's a folder.
return bool

IsSubfolder() public method

public IsSubfolder ( string parentPath, string childPath ) : bool
parentPath string
childPath string
return bool

MakeRelativePath() public method

Creates a relative path from one file or folder to another.
public MakeRelativePath ( string fromPath, string toPath ) : string
fromPath string Contains the directory that defines the start of the relative path.
toPath string Contains the path that defines the endpoint of the relative path.
return string

ReadAllText() public method

Reads a text file from disk
public ReadAllText ( string path ) : string
path string The path to the file to read.
return string

SetFileReadOnly() public method

Toggles the Read-Only attribute on a file
public SetFileReadOnly ( string filePath, bool isReadOnly ) : void
filePath string The path to the file.
isReadOnly bool Whether or not to set the read only flag.
return void

WriteTextToFile() public method

Writes a text file to disk
public WriteTextToFile ( string path, string fileContents ) : void
path string The path of the file to write to.
fileContents string The contents to write.
return void