ASP.NET - saving temporary files

I have a web form that allows users to upload files when they open a ticket on our system. Downloading is performed using the asyncFileUpload control "ajax control toolkit".

The idea is to save the files in the temp directory and only save them in a permanent place when the user clicks the commit button.

I would like to be able to get rid of temporary files that are no longer relevant (for example, the user leaves the page open for a month without submitting the form).

What would be the best way to not store temporary files forever. Maybe store files in a session? Maybe keep them in view?

I could add JS to the timeout page and add code that runs when the user leaves the page. But these ideas are customer solutions. I would not want anyone to interfere with the code and leave me trash in my system.

Any other idea?

Thanks Summerbulb

+5
source share
4 answers

, On_SessionEnd Global.asax . , SessionID ( SessionID, , ), , . On_Application_End Global.asax, temp.

+3

?

. , , .

, ?

. , - ( ) . ( , , ).


, ? ( SQL)? , , .

Windows . , , , . , , , ..

+7

. , :

var dir = System.IO.Path.GetTempPath();

(Windows) .

http://msdn.microsoft.com/en-us/library/system.io.path.gettemppath.aspx

+1

In the declaration, you can execute the System.IO.File.Move () command. The remaining files can be deleted using the service or console application, if you have access to the server for this.

0
source

All Articles