Reputation: 657
I am trying to build a directory structure based on some object names and values to hold pictures and files, I am seeding some data into the DB and have a create option for the table in question. Where is a good place in the project to write this code to make it the least fragile?
Upvotes: 0
Views: 92
Reputation: 69250
If creating the directory to store the files in is is part of global application initalization, I'd recommend to check if the directory exists and create it if it doesn't in Application_Start()
in global.asax.cs
.
Also note that adding/changing files to an ASP.NET site during runtime causes the application to restart (the idea is that you can update a config file, or an aspx.cs file and the change will take effect). For data files you don't want that behaviour, so make sure to place your files under the special App_Data
directory that is meant for data.
Upvotes: 1