C# Class Oglr.Core.Disk

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

Méthodes publiques

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

Méthode Description
areSameFolders ( DirectoryInfo left, DirectoryInfo right ) : bool
isDirectory ( string path ) : bool
isFileReadOnly ( string path ) : bool

Method Details

Combine() public méthode

public Combine ( string firstPart, string secondPart ) : string
firstPart string
secondPart string
Résultat string

CopyFolder() public méthode

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

CreateDirectoryIfDoesNotExist() public méthode

public CreateDirectoryIfDoesNotExist ( string directoryPath ) : void
directoryPath string
Résultat void

DeleteFileOrDirectory() public méthode

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

DeleteFilesOrDirectories() public méthode

Deletes the files or directories.
public DeleteFilesOrDirectories ( IEnumerable paths ) : void
paths IEnumerable The paths.
Résultat void

FileExists() public méthode

public FileExists ( string localPath ) : bool
localPath string
Résultat bool

FilenamesInDirectory() public méthode

public FilenamesInDirectory ( string pathToFolder, string searchPattern, SearchOption searchOption ) : IEnumerable
pathToFolder string
searchPattern string
searchOption SearchOption
Résultat IEnumerable

FolderExists() public méthode

public FolderExists ( string pathToFolder ) : bool
pathToFolder string
Résultat bool

GetChildDirectoriesRecursively() public méthode

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

GetDirectoryNameFromPath() public méthode

public GetDirectoryNameFromPath ( string path ) : string
path string
Résultat string

GetEntityType() public méthode

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

GetFilesInDirectoryRecursively() public méthode

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

GetTempPath() public méthode

public GetTempPath ( ) : string
Résultat string

IsFile() public méthode

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

IsFolder() public méthode

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

IsSubfolder() public méthode

public IsSubfolder ( string parentPath, string childPath ) : bool
parentPath string
childPath string
Résultat bool

MakeRelativePath() public méthode

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

ReadAllText() public méthode

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

SetFileReadOnly() public méthode

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

WriteTextToFile() public méthode

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