Click here to Skip to main content
15,890,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm making a project on social networking site in asp.net and I want to ask a question regarding this . I want to make a story update feature like Whatsapp and for that the image uploaded should gets deleted automatically after a day . I want to ask how to do that . Means how to make a picture uploaded at once and gets deleted after exactly a day in asp.net ?

What I have tried:

I've tried to delete it manually and it works well , but i want to delete it automatically after certain time like may be after a day .
Posted
Updated 16-Jun-19 10:30am
Comments
F-ES Sitecore 17-Jun-19 3:47am    
In addition to what OriginalGriff said, you can use a library like quartz.net to schedule your asp.net code to run so you can do an hourly task to delete old images. It's not as reliable as a scheduled task or a service but if you're not able to use those then it's a decent alternative.

1 solution

There is no way to automatically expire and delete images or any other files, you will have to do something yourself to remove them.
The way I would do it is to add a scheduled task to remove them (Windows and most hosting services provide some mechanism for this) and have run every hour or so.
Then I'd add an expiry date and time to each image as part of a database (file location, name, expiry, any other info you wanted) and write a quick app which pulled the expired rows from the DB and removed the file, and then the row.
Run that every hour, and the files disappear as if by magic.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900