I have 2 excel sheets inside my Asp.net core MVC web application under a folder named "Files" as follow:-
Where i am referencing these files inside my TextFieldParser method as follow:-
public class HomeController : Controller { protected IWebHostEnvironment _host; // using Microsoft.AspNetCore.Hosting public HomeController(IWebHostEnvironment webHostEnvironment) { _host = webHostEnvironment; } public IActionResult Index() { string YOURCURRENTFILE = _host.ContentRootPath + @"/Files/v2.csv";
using (TextFieldParser parser = new TextFieldParser(YOURCURRENTFILE ))
{ // USE YOUR TextFieldParser logic } }
inside my startup.cs
i have the following app.UseStaticFiles();
as follow:-
publicvoidConfigure(IApplicationBuilder app,IWebHostEnvironment env){if(env.IsDevelopment()){}else{
app.UseStaticFiles();
so in my case can users directly access the files? or they can only access them through my action methods?