Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

[Question] File isn't copied on debug.

$
0
0

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.


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>