Hey guys, I apologize for this basic question, but for the life of me I can't seem to find an answer.
I previously asked a question here about how to dynamically store temporary images and handle their cleanup on a web server's file system. (using C# in .NET 3.5)
It was suggested that I use a global.asax file to handle this.
I just can't figure out how this thing works.
I have two separate applications... So far, I have figured out that the global.asax is supposed to be in the root directory of the website.
Questions:
1) How to I get the global.asax to fire for only these two specific applications.
2) both applications need to create a list of strings (the file locations) then delete them on the application termination. Do I instantiate this array in the app, or in the global.asax?
my code will look like this
List<string> fileLocations = new List<string>(); //I don't know where to put this.
//The next line of code will be in both applications (this could be called many times in one application session. The names of the files are generated from the clock (milliseconds and seconds combined, I might change this to use the actual random class combined with sessionID)
fileLocations.Add(file);
void Application_End(object sender, EventArgs e)
{
// Code that runs on application shutdown
foreach(string file in fileLocations)
{
if(File.Exists(file))
File.Delete(file);
}
}
I am confused about how the global.asax actually works. Is it used like an interface?