C# Класс Oglr.Core.Disk

Represents a disk. A facade over the Path and File API's.
Наследование: IDisk
Показать файл Открыть проект Примеры использования класса

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

Метод Описание
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

Приватные методы

Метод Описание
areSameFolders ( DirectoryInfo left, DirectoryInfo right ) : bool
isDirectory ( string path ) : bool
isFileReadOnly ( string path ) : bool

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

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

public Combine ( string firstPart, string secondPart ) : string
firstPart string
secondPart string
Результат string

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

Copies the folder.
public CopyFolder ( string fromDirectory, string toDirectory ) : void
fromDirectory string From directory.
toDirectory string To directory.
Результат void

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

public CreateDirectoryIfDoesNotExist ( string directoryPath ) : void
directoryPath string
Результат void

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

Deletes the file or directory.
public DeleteFileOrDirectory ( string path ) : void
path string The path to the file or directory.
Результат void

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

Deletes the files or directories.
public DeleteFilesOrDirectories ( IEnumerable paths ) : void
paths IEnumerable The paths.
Результат void

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

public FileExists ( string localPath ) : bool
localPath string
Результат bool

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

public FilenamesInDirectory ( string pathToFolder, string searchPattern, SearchOption searchOption ) : IEnumerable
pathToFolder string
searchPattern string
searchOption SearchOption
Результат IEnumerable

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

public FolderExists ( string pathToFolder ) : bool
pathToFolder string
Результат bool

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

Builds a list containing all the files under a specific directory
public GetChildDirectoriesRecursively ( string directory ) : IEnumerable
directory string The parent directory.
Результат IEnumerable

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

public GetDirectoryNameFromPath ( string path ) : string
path string
Результат string

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

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.
Результат DiskEntity

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

Builds a list containing all the files under a specific directory
public GetFilesInDirectoryRecursively ( string directory ) : IEnumerable
directory string The parent directory.
Результат IEnumerable

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

public GetTempPath ( ) : string
Результат string

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

Determines whether the specified path is a file.
public IsFile ( string path ) : bool
path string The path to the disk entity.
Результат bool

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

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.
Результат bool

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

public IsSubfolder ( string parentPath, string childPath ) : bool
parentPath string
childPath string
Результат bool

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

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.
Результат string

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

Reads a text file from disk
public ReadAllText ( string path ) : string
path string The path to the file to read.
Результат string

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

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.
Результат void

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

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.
Результат void