Click here to Skip to main content
15,915,691 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I have application through which i am uploading data like images,videos in database and in one folder.
I want to develop a console application through which i want to delete unwanted files from database as well as from folder.

I have my stored procedure which deletes all the data from database except top 10.Now i want to delete the image files which is not in database.

Please give some relevant solution.

Regards
Posted

hi,
How will u check?
I mean have u stored the path of those images in database? if yes, then get those unwanted paths from the database and delete them.
 
Share this answer
 
Comments
richa11 24-Apr-13 6:30am    
Yes I have paths stored in database.Can you please tell me how to do it.
[no name] 24-Apr-13 6:32am    
Get the file path from your database and use File.Delete to delete the file.
richa11 24-Apr-13 6:38am    
I have different paths for different file.
for example i have one common folder images ,in images folder i have different case folder like case 1 ,case 2 and all these case folder is having their images.I have deletes all cases as well as images from database i have left with 3 cases i want to delete all case images from folder except 3 cases.
Rockstar_ 24-Apr-13 6:39am    
No problem, Check my 2nd solution.and read the link, you will get idea.
Hi,

Directory.GetFiles(@"c:\MyDir\")
Before using the Above statement get the paths from the database.
Please look into the below link for further information.

http://www.csharp-examples.net/delete-all-files/[^]
 
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