dotnet-directory-files-utility
1.1.0
dotnet add package dotnet-directory-files-utility --version 1.1.0
NuGet\Install-Package dotnet-directory-files-utility -Version 1.1.0
<PackageReference Include="dotnet-directory-files-utility" Version="1.1.0" />
<PackageVersion Include="dotnet-directory-files-utility" Version="1.1.0" />
<PackageReference Include="dotnet-directory-files-utility" />
paket add dotnet-directory-files-utility --version 1.1.0
#r "nuget: dotnet-directory-files-utility, 1.1.0"
#addin nuget:?package=dotnet-directory-files-utility&version=1.1.0
#tool nuget:?package=dotnet-directory-files-utility&version=1.1.0
Files Folders Utility
About | Technology | Installation | Configuration
About
This is a utility to aid in directory management for .NET Web or .NET API applications and includes tools to conveniently look up physical and server paths based on mapped directories
Technology
Installation
To install and use this tool, you will need to install the nuget package and register the service in your application settings.
Configuration
A good practice recommendation is to store the names of the directories you want to map in constants, so it will be easier to manage the directories later, for example.
public static class Consts
{
public const string FilesFolder = "Files";
public const string TempFolder = "Temp";
public const string ImagesFolder = "Images";
}
After downloading and installing the package, you need to register the service to use it in your application, it is mandatory to add at least one directory in the mapping settings, in case of mapping subdirectories the name of the parent directory must always precede the name of the child directory as example to follow:
public void ConfigureServices(IServiceCollection services)
{
services.RegisterDirectoriesFilesUtility(o =>
{
o.AddFolder(parent: Consts.FilesFolder, name: Consts.ImagesFolder);
o.AddFolder(name: Consts.TempFolder);
o.AddFolder(name: Consts.FilesFolder);
});
}
Samples
After registering the service, you can use it like any other dependency injection in the context of your application, as shown in the following example.
public class HomeController : Controller
{
private readonly ILogger<HomeController> _logger;
private readonly IDirectoriesFilesUtility _utility;
public HomeController(ILogger<HomeController> logger, IDirectoriesFilesUtility utility)
{
_utility = utility;
_logger = logger;
}
public IActionResult Index()
{
HttpClient cli = new HttpClient();
Stream sampleStream = cli
.GetStreamAsync("https://images.pexels.com/photos/15476378/pexels-photo-15476378.jpeg")
.Result;
//you can omit the parameter if you want to get the directory only
string destination = _utility.GetPath(Consts.FilesFolder, "sample.jpg");
string source = _utility.GetPath(Consts.ImagesFolder, "sample.jpg");
string sourceUrl = _utility.GetUrl(Consts.ImagesFolder, "sample.jpg");
string streamName = _utility.WriteFile(sampleStream, source).Result;
string copyName = _utility.CopyFile(source, destination);
string moveName = _utility.MoveFile(source, destination);
return View();
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.AspNetCore.Http (>= 2.2.2)
- Microsoft.Extensions.Hosting (>= 6.0.1)
- Microsoft.Extensions.Hosting.Abstractions (>= 7.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
rollback minimal dependencies version for compatibility