C# Class Bari.Core.Generic.FileSystemDirectoryExtensions

Extension methods for the IFileSystemDirectory interface
Datei anzeigen Open project: vigoo/bari

Public Methods

Method Description
CreateBinaryFileWithDirectories ( this root, string relativePath ) : Stream

Creates a binary file in the given directory, or in a subdirectory of it. If the subdirectory does not exist, it will be created.

GetChildDirectory ( this root, string childName, bool createIfMissing ) : IFileSystemDirectory

Gets a child directory and optionally creates it if missing

GetRelativePathFrom ( this root, IFileSystemDirectory innerRoot, string outerRelativePath ) : string

Gets the relative path from a given directory to given file in a larger common directory subtree. r.Object.GetRelativePathFrom(a.Object, @"a\c.txt").Should().Be(@"c.txt"); r.Object.GetRelativePathFrom(a.Object, @"a.test\e.txt").Should().Be(@"..\a.test\e.txt"); r.Object.GetRelativePathFrom(a.Object, @"b\d.txt").Should().Be(@"..\b\d.txt");

Method Details

CreateBinaryFileWithDirectories() public static method

Creates a binary file in the given directory, or in a subdirectory of it. If the subdirectory does not exist, it will be created.
public static CreateBinaryFileWithDirectories ( this root, string relativePath ) : Stream
root this The root directory
relativePath string Relative path of the file to be created
return Stream

GetChildDirectory() public static method

Gets a child directory and optionally creates it if missing
Thrown if the child directory does not exist and createIfMissing parameter is false
public static GetChildDirectory ( this root, string childName, bool createIfMissing ) : IFileSystemDirectory
root this The root directory
childName string The name of the direct child directory
createIfMissing bool If true, the child directory will be created if does not exist
return IFileSystemDirectory

GetRelativePathFrom() public static method

Gets the relative path from a given directory to given file in a larger common directory subtree. r.Object.GetRelativePathFrom(a.Object, @"a\c.txt").Should().Be(@"c.txt"); r.Object.GetRelativePathFrom(a.Object, @"a.test\e.txt").Should().Be(@"..\a.test\e.txt"); r.Object.GetRelativePathFrom(a.Object, @"b\d.txt").Should().Be(@"..\b\d.txt");
public static GetRelativePathFrom ( this root, IFileSystemDirectory innerRoot, string outerRelativePath ) : string
root this The directory subtree which contains both innerRoot and outerRelativePath
innerRoot IFileSystemDirectory The directory to get the path relative to
outerRelativePath string The target path, relative to the root directory
return string