In startup I have set my IFileProvider in configure services as follows:
IFileProvider physicalProvider = new PhysicalFileProvider(Directory.GetParent(env.ContentRootPath).ToString());
services.AddSingleton<IFileProvider>(physicalProvider);
Now when I go to use to find the files last modified date in my controller I get date 01/01/0001 for all files. My code is as follows:
private readonly IWebHostEnvironment env;
private IFileProvider _fileProvider;
public IConfiguration Configuration { get; }
public MainReviewController(LoginDBContext context, IConfiguration configuration, IWebHostEnvironment env, IFileProvider fileProvider)
{
_context = context;
connectionString = configuration["ConnectionStrings:DBContext"];
this.env = env;
_fileProvider = fileProvider;
}
After I use dependency injection to use the file provider I use the following code in my post request
var rootPath = Path.Combine(Directory.GetParent(env.ContentRootPath).ToString(), "ARMSFiles");
foreach (var file in mainreviewdocuments)
{
var filePath = Path.Combine(rootPath, file.DOCUMENT_FULL_PATH);
System.Diagnostics.Debug.WriteLine(filePath);
System.Diagnostics.Debug.WriteLine(_fileProvider.GetFileInfo(filePath).LastModified);
}
Any ideas on this? In my startup i use dependency injection as well to ensure i am using the same env variable as my controller so the directories should line up. It is basically a folder outside of my root folder since that is a bit more secure and I use it for a webdav when I actually deploy this.

