|
1 | 1 |  |
2 | 2 | [](https://www.nuget.org/packages/TestableIO.System.IO.Abstractions.Extensions) |
3 | 3 |  |
4 | | -[](https://app.codacy.com/gh/System-IO-Abstractions/System.IO.Abstractions.Extensions?utm_source=github.com&utm_medium=referral&utm_content=System-IO-Abstractions/System.IO.Abstractions.Extensions&utm_campaign=Badge_Grade_Dashboard) |
5 | 4 | [](https://renovatebot.com/) |
6 | | -[](https://app.fossa.com/projects/git%2Bgithub.com%2FSystem-IO-Abstractions%2FSystem.IO.Abstractions.Extensions?ref=badge_shield) |
| 5 | +<!-- [](https://app.codacy.com/gh/TestableIO/System.IO.Abstractions.Extensions?utm_source=github.com&utm_medium=referral&utm_content=TestableIO/System.IO.Abstractions.Extensions&utm_campaign=Badge_Grade_Dashboard) --> |
| 6 | +<!-- [](https://app.fossa.com/projects/git%2Bgithub.com%2FTestableIO%2FSystem.IO.Abstractions.Extensions?ref=badge_shield) --> |
7 | 7 |
|
8 | 8 | Convenience functionality on top of System.IO.Abstractions |
9 | 9 |
|
10 | 10 | ```shell |
11 | 11 | dotnet add package TestableIO.System.IO.Abstractions.Extensions |
12 | 12 | ``` |
| 13 | + |
| 14 | +# Examples |
| 15 | + |
| 16 | +## CurrentDirectory extension |
| 17 | + |
| 18 | +```csharp |
| 19 | +var fs = new FileSystem(); |
| 20 | + |
| 21 | +//with extension |
| 22 | +var current = fs.CurrentDirectory(); |
| 23 | + |
| 24 | +//without extension |
| 25 | +var current = fs.DirectoryInfo.FromDirectoryName(fs.Directory.GetCurrentDirectory()); |
| 26 | +``` |
| 27 | + |
| 28 | +## SubDirectory extension |
| 29 | + |
| 30 | +```csharp |
| 31 | +var current = new FileSystem().CurrentDirectory(); |
| 32 | + |
| 33 | +//create a "temp" subdirectory with extension |
| 34 | +current.SubDirectory("temp").Create(); |
| 35 | + |
| 36 | +//create a "temp" subdirectory without extension |
| 37 | +current.FileSystem.DirectoryInfo.FromDirectoryName(current.FileSystem.Path.Combine(current.FullName, "temp")).Create(); |
| 38 | +``` |
| 39 | + |
| 40 | +## File extension |
| 41 | + |
| 42 | +```csharp |
| 43 | +var current = new FileSystem().CurrentDirectory(); |
| 44 | + |
| 45 | +//create a "test.txt" file with extension |
| 46 | +using (var stream = current.File("test.txt").Create()) |
| 47 | + stream.Dispose(); |
| 48 | + |
| 49 | +//create a "test.txt" file without extension |
| 50 | +using (var stream = current.FileSystem.FileInfo.FromFileName(current.FileSystem.Path.Combine(current.FullName, "test.txt")).Create()) |
| 51 | + stream.Dispose(); |
| 52 | +``` |
0 commit comments