C# On Quit WebPage Delete Files and Folders on Server with no user action


I have some problems to delete temporary folder and files on my server when users not finish some action in webpages and quit to other webpages. Initialy at Page Load folders are created to allow the user to load files.I have tried implementing destruction during Idisposable without success. Could someone point the best method to delete folders and files when user quit the page with no action or cancel button.


You can investigate the OnUnload event of the page but, honestly, your best bet is to have a script run periodically and delete all files from the temp folder older than some reasonable amount. e.g. run at midnight and delete all files created more the 24 hours ago (or less, if disk space is a problem).


I am not sure why you want to create temp folders and files. But deleting them on no action is ugly way to rely on, because you have depend on some timers. You could use System.IO.Path.GetTempPath() to get a temp file and system would take care of deletion.


  • Composition in UML
  • how to defer delete operation of shared_ptr?
  • Transparent Winform with image
  • Dequeue from Queue with where expression
  • Scheduling a java.util.concurrent.Callable through Spring means
  • Understanding on Termination Connector of State Diagram in IBM Rhapsody
  • Return a Disposable object for use in a using block
  • instance of class held by composition container in mef
  • Avoid Collection has been modified error
  • Complex trait requirements on struct
  • Simple Factory with reflection C#
  • Build Matrix of Comparisons in SQl Server
  • A class implementing two different IObservables?
  • How to explicitly/implicitly implemented interface members in C++/CLI?
  • pillow imaging ImportError
  • how does System.Web.HttpRequest::PathInfo work?
  • IE11 throwing “SCRIPT1014: invalid character” where all other browsers work
  • C# program and C++ DLL compiled for 32-bit system crash on 64-bit system
  • nonblocking BIO_do_connect blocked when there is no internet connected
  • Not able to aggregate on nested fields in elasticsearch
  • Firefox Extension - Monitor refresh and change of tab
  • Loading .coffee files via a view in Rails
  • Create DicomImage from scratch using Dcmtk
  • onBackPressed() not being executed
  • Android fill_parent issue
  • Get data from AJAX - How to
  • Bug in WPF DataGrid
  • Incrementing object id automatically JS constructor (static method and variable)
  • jquery mobile loadPage not working
  • Properly structure and highlight a GtkPopoverMenu using PyGObject
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • How can I get HTML syntax highlighting in my editor for CakePHP?
  • Free memory of cv::Mat loaded using FileStorage API
  • Turn off referential integrity in Derby? is it possible?
  • Authorize attributes not working in MVC 4
  • unknown Exception android
  • Busy indicator not showing up in wpf window [duplicate]
  • Python/Django TangoWithDjango Models and Databases
  • Net Present Value in Excel for Grouped Recurring CF
  • How to load view controller without button in storyboard?