So rather than getting my hands dirty editing and recompiling zedgraphweb http://sourceforge.net/projects/zedgraph, I chose a more common apporach, dealing with the amount of files myself. I am using the Cache's CacheItemRemovedCallback to execute code in a web app like using a timer. Aslo this code refills the cache item and therefore renews the cycle. voila: disk cleanup every 5 minutes in a web app.
Public Module Maintenance
Private Const triggerKey As String = "MaintenanceDiskCleaner"
Friend Sub Run()
Try
SyncLock triggerKey
If Hosting.HostingEnvironment.Cache(triggerKey) Is Nothing Then
Hosting.HostingEnvironment.Cache.Add(triggerKey, _
DateTime.Now, _
Nothing, _
DateTime.Now.AddMinutes(5), _
Cache.NoSlidingExpiration, _
CacheItemPriority.Default, _
AddressOf CacheItemRemovedCallback)
End If
End SyncLock
Catch ex As Exception
End Try
End Sub
Public Sub CacheItemRemovedCallback(ByVal key As String, ByVal value As Object, ByVal reason As CacheItemRemovedReason)
Try
Dim dir As String = Hosting.HostingEnvironment.MapPath("~\ZedGraphImages")
If Directory.Exists(dir) Then
SyncLock triggerKey
Dim di As DirectoryInfo = New DirectoryInfo(dir)
Dim files As FileSystemInfo() = di.GetFileSystemInfos()
For Each file As FileSystemInfo In From f In files Where f.CreationTime < CType(value, DateTime)
Try
WebTools.Files.TryDelete(file.Name, 50)
Catch ex As Exception
End Try
Next
End SyncLock
End If
Run()
Catch ex As Exception
End Try
End Sub
End Module