|
2 | 2 |
|
3 | 3 | <!-- A description of the package and where one can find more documentation --> |
4 | 4 |
|
| 5 | +Provides an implementation of a physical file provider, facilitating file access and monitoring on the disk. The primary type, [`PhysicalFileProvider`](https://learn.microsoft.com/dotnet/api/microsoft.extensions.fileproviders.physicalfileprovider), enables the lookup of files on disk and can watch for changes either via `FileSystemWatcher` or polling mechanisms. |
5 | 6 |
|
6 | 7 |
|
7 | 8 | ## Key Features |
8 | 9 |
|
9 | 10 | <!-- The key features of this package --> |
10 | 11 |
|
11 | | -* |
12 | | -* |
13 | | -* |
| 12 | +* Easy access and monitoring of files on the disk. |
| 13 | +* Ability to watch for file changes either by using `FileSystemWatcher` or through polling. |
14 | 14 |
|
15 | 15 | ## How to Use |
16 | 16 |
|
17 | 17 | <!-- A compelling example on how to use this package with code, as well as any specific guidelines for when to use the package --> |
18 | 18 |
|
| 19 | +This library can be used to look up files on disk and monitor file changes effectively. |
| 20 | +Below is an example of how to use the `PhysicalFileProvider` to access files on disk and monitor changes: |
| 21 | + |
| 22 | +```c# |
| 23 | +using Microsoft.Extensions.FileProviders; |
| 24 | +using Microsoft.Extensions.FileProviders.Physical; |
| 25 | + |
| 26 | +using var provider = new PhysicalFileProvider(AppContext.BaseDirectory); |
| 27 | + |
| 28 | +Environment.SetEnvironmentVariable("DOTNET_USE_POLLING_FILE_WATCHER", "1"); |
| 29 | + |
| 30 | +var contents = provider.GetDirectoryContents(string.Empty); |
| 31 | +foreach (PhysicalFileInfo fileInfo in contents) |
| 32 | +{ |
| 33 | + Console.WriteLine(fileInfo.PhysicalPath); |
| 34 | +} |
| 35 | + |
| 36 | +var changeToken = provider.Watch("*.txt"); |
| 37 | +changeToken.RegisterChangeCallback(_ => Console.WriteLine("Text file changed"), null); |
| 38 | + |
| 39 | +Console.ReadLine(); |
| 40 | +``` |
| 41 | + |
19 | 42 | ## Main Types |
20 | 43 |
|
21 | 44 | <!-- The main types provided in this library --> |
22 | 45 |
|
23 | 46 | The main types provided by this library are: |
24 | 47 |
|
25 | | -* `` |
26 | | -* `` |
27 | | -* `` |
| 48 | +* `Microsoft.Extensions.FileProviders.PhysicalFileProvider` |
| 49 | +* `Microsoft.Extensions.FileProviders.PhysicalDirectoryInfo` |
| 50 | +* `Microsoft.Extensions.FileProviders.PhysicalFileInfo` |
28 | 51 |
|
29 | 52 | ## Additional Documentation |
30 | 53 |
|
31 | 54 | <!-- Links to further documentation. Remove conceptual documentation if not available for the library. --> |
32 | 55 |
|
33 | | -* [Conceptual documentation](https://learn.microsoft.com/en-us/dotnet/standard/serialization/**LIBRARYNAME**/overview) |
34 | | -* [API documentation](https://learn.microsoft.com/en-us/dotnet/api/**LIBRARYNAME**) |
| 56 | +* [Conceptual documentation](https://learn.microsoft.com/aspnet/core/fundamentals/file-providers#physical-file-provider) |
| 57 | +* [API documentation](https://learn.microsoft.com/dotnet/api/microsoft.extensions.fileproviders.physical) |
35 | 58 |
|
36 | 59 | ## Related Packages |
37 | 60 |
|
38 | 61 | <!-- The related packages associated with this package --> |
39 | 62 |
|
| 63 | +* Abstractions of files and directories: [Microsoft.Extensions.FileProviders.Abstractions](https://www.nuget.org/packages/Microsoft.Extensions.FileProviders.Abstractions/) |
| 64 | +* File system globbing to find files matching a specified pattern: [Microsoft.Extensions.FileSystemGlobbing](https://www.nuget.org/packages/Microsoft.Extensions.FileSystemGlobbing/) |
| 65 | + |
40 | 66 | ## Feedback & Contributing |
41 | 67 |
|
42 | 68 | <!-- How to provide feedback on this package and contribute to it --> |
43 | 69 |
|
44 | | -Microsoft.Extensions.FileProviders.Physical is released as open source under the [MIT license](https://licenses.nuget.org/MIT). Bug reports and contributions are welcome at [the GitHub repository](https://github.com/dotnet/runtime). |
| 70 | +Microsoft.Extensions.FileProviders.Physical is released as open source under the [MIT license](https://licenses.nuget.org/MIT). Bug reports and contributions are welcome at [the GitHub repository](https://github.com/dotnet/runtime). |
0 commit comments