Hi everyone,
I'm creating a web api 2 project which uses a json file as a database.
I used MapPath to get the physic path of my data file, but when I check the file, it doesn't exist.
My question is : How can I make my data file be copied to output folder when I press F5 to start debugging ?
Here is my function :
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { #region Default initialization loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); app.UseIISPlatformHandler(); app.UseApplicationInsightsRequestTelemetry(); app.UseApplicationInsightsExceptionTelemetry(); app.UseStaticFiles(); app.UseMvc(); #endregion // Retrieve application settings which are defined in appsettings.json. var applicationSettings = Configuration.Get<ApplicationSettings>("ApplicationSettings"); #region Retrieve foods data. // Retrieve food from file. var foodDataFile = env.MapPath(applicationSettings.VirtualFoodDataFile); // Retrieve foods information from data file and store 'em to a list. ExternalDataHelper.Instance.RetrieveFoodsFromFile(foodDataFile); #endregion }
Can anyone help me please ?
Thank you.