In my codebehind I’m currently saving documents to a folder on the server. If the document is temporary I append “_temp” to the filename. On page load I want to check the server folder where these documents are held and I want to delete any of the temporary documents. i.e. the files that end with “_temp”.
What would be the best way to do this?
or using linq
Once you get all the files then you need to iterate through the results and delete them one by one. However this could be expensive for an asp.net site. Also you need to make sure that simultaneous requests does not throw exceptions!
I would recommend that temp files are stored in a single directory rather than put them in a dir that is shared with non temp files. Just for clarity and peace of mind.