简体   繁体   中英

File structure for storing pictures and files ASP.NET MVC

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM