-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Open
Labels
Description
In ASP.NET framework 4.8 and below version the web application use IIS for processing and show data. Ans I web need to work with other resource like folders and network resource we can easily create Virtual Directory in IIS and map to physical path and in Asp.net application work like normal folder but in Net Core we use Kestrel and IIS work as a proxy and Virtual Directory not recognized by Kestrel. I use this code but not work in function. Write this section in Configure Function
app.UseFileServer(new FileServerOptions
{
FileProvider = new PhysicalFileProvider(@"E:\\MyFiles"),
RequestPath = new PathString("/PFiles"),
EnableDirectoryBrowsing = true
});
var folder = Path.Combine(environment.WebRootPath, "temp");
var fileName = Path.Combine(environment.WebRootPath, "temp\\test.jpeg");
var basePath = Path.Combine(environment.WebRootPath, "PFiles");
var yearPath = Path.Combine(basePath, "2020");
var monthpath = Path.Combine(basePath, "2020", "06");
if (!Directory.Exists(yearPath))
{
Directory.CreateDirectory(yearPath);
}
if (!Directory.Exists(monthpath))
{
Directory.CreateDirectory(monthpath);
}
var dpath = Path.Combine(basePath, "2020", "06");
var destinationPath = Path.Combine(environment.WebRootPath, dpath);
System.IO.File.Move(fileName, destinationPath);
but I receive Access denied Error or create directory inside of wwwroot folder. So, what must I do?