Overview
TheHelperPathProvider class provides methods to map file names to physical paths and URL paths within the web application’s folder structure. It supports multiple predefined folders for organizing different types of files.
Namespace: MvcNetCoreUtilidades.Helpers
Folders Enum
Images- Maps to “images” folderfacturas- Maps to “facturas” folderUploads- Maps to “uploads” folderTemporal- Maps to “temp” folder
Constructor
HelperPathProvider class.
The web host environment used to access the application’s root path
The server instance used to access server addresses for URL generation
Methods
MapPath
The name of the file (including extension)
The folder type where the file is located (from the
Folders enum)string - The complete physical path to the file
Usage:
MapUrlPath
The name of the file (including extension)
The folder type where the file is located (from the
Folders enum)string - The complete URL path to the file
Usage:
Folder Mappings
| Enum Value | Physical Folder |
|---|---|
Folders.Images | images |
Folders.facturas | facturas |
Folders.Uploads | uploads |
Folders.Temporal | temp |
Dependency Injection
Register the helper in yourProgram.cs: