Skip to content

Commit d236b6e

Browse files
committed
Added usage examples
1 parent c67f492 commit d236b6e

File tree

1 file changed

+42
-2
lines changed

1 file changed

+42
-2
lines changed

README.md

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,52 @@
11
![System.IO.Abstractions.Extensions](https://socialify.git.ci/System-IO-Abstractions/System.IO.Abstractions.Extensions/image?description=1&font=Source%20Code%20Pro&forks=1&issues=1&pattern=Charlie%20Brown&pulls=1&stargazers=1&theme=Dark)
22
[![NuGet](https://img.shields.io/nuget/v/TestableIO.System.IO.Abstractions.Extensions.svg)](https://www.nuget.org/packages/TestableIO.System.IO.Abstractions.Extensions)
33
![Continuous Integration](https://github.com/TestableIO/System.IO.Abstractions.Extensions/workflows/Continuous%20Integration/badge.svg)
4-
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/2e777fa545c94767acccd6345b1ed9b7)](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)
54
[![Renovate enabled](https://img.shields.io/badge/renovate-enabled-brightgreen.svg)](https://renovatebot.com/)
6-
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2FSystem-IO-Abstractions%2FSystem.IO.Abstractions.Extensions.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2FSystem-IO-Abstractions%2FSystem.IO.Abstractions.Extensions?ref=badge_shield)
5+
<!-- [![Codacy Badge](https://api.codacy.com/project/badge/Grade/2e777fa545c94767acccd6345b1ed9b7)](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+
<!-- [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2FTestableIO%2FSystem.IO.Abstractions.Extensions.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2FTestableIO%2FSystem.IO.Abstractions.Extensions?ref=badge_shield) -->
77

88
Convenience functionality on top of System.IO.Abstractions
99

1010
```shell
1111
dotnet add package TestableIO.System.IO.Abstractions.Extensions
1212
```
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

Comments
 (0)