Last post Sep 29, 2009 10:36 PM by april_123456
Sep 22, 2009 04:49 AM|icm63|LINK
<%@ Application Language="VB" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.IO.Compression" %>
Sub Application_End(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs on application shutdown
Dim files2 As String() = System.IO.Directory.GetFiles(Server.MapPath("~/Members"), "*.xls")
For Each file2 As String In files2
Running code from my localhost windows xp asp.net 2.0 ajax project, this code is supposed to clear all xls files in the members directory. When I run view browser, and close project ( via browser X), this code does not run..any ideas????
Sep 22, 2009 05:00 AM|qwe123kids|LINK
Global.asax is ile in which u should Sritw code what u have written not in .ascx file..
.ascx file is file for user control
the above link help u write and understding of .ascx file
Sep 22, 2009 05:18 AM|subhashdike|LINK
The code is working, but you are doing an incorrect thing inside the Application_End event. (If you refer to your event log, you can easily figure this out)
You cannot call the
Server.MapPath method in the
Refer to this link
http://msdn.microsoft.com/en-us/library/ms524858.aspx for more details.
Mark as an answer if this helps
Sep 22, 2009 12:20 PM|icm63|LINK
Thanks, so were can I run code at the end of a user session to delete unwanted files, generated by that user ???
Sep 23, 2009 12:32 AM|subhashdike|LINK
One solution I can think of is writing a custom http module and add you cleanup code on session_end or application_end event. I have not tried this myself.
A link below would guide you for custom httpmodule.
Sep 29, 2009 08:02 AM|april_123456|LINK
I suggest you using a System.Timers.Timer to do the work periodically. And the timer can be started in Application_Start method of global.ascx
Sep 29, 2009 02:03 PM|icm63|LINK
Ok, but can I user server path function in the "Application_Start" part of the global page within Asp.net 2.0 ???
Sep 29, 2009 10:36 PM|april_123456|LINK
Yes, you can call the "Server. Mappath" method in the "Application_Start" part.