I am uploading image files in my mvc web app. I want to show this as logo on my site whenever I upload any selected image. For this, i need to clear the browser cache. Following is set of funtions I am using for clearing cache.
void clearIECache()
{
ClearFolder(new DirectoryInfo(Environment.GetFolderPath
(Environment.SpecialFolder.InternetCache)));
}
void ClearFolder(DirectoryInfo folder)
{
foreach (FileInfo file in folder.GetFiles())
{ file.Delete(); }
foreach (DirectoryInfo subfolder in folder.GetDirectories())
{ ClearFolder(subfolder); }
}
Problem with above code is that it interrupts whenever it tries to delete any file that's in use. I want to skip such files sothat it can work smoothly. Is there any way to achieve this?
thanks, kapil