Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically Copy Files from 'Temporary Internet Files' into other directory

I need to copy all images from Temperary Internet Files to some other directory. I tried using below code

string[] IeImageFiles = Directory.GetFiles(
  Environment.GetFolderPath(Environment.SpecialFolder.InternetCache).ToString());

the problem is that GetFiles method returns only few files. Whereas I can see many files in the same folder when I browse through internet explorer 'View Files'(IE options -> General Tab -> Settings ->Temporary internet Files).

I need to know the physical path so as to query the directory and get the files. How to achieve that. Any help greatly appreciated.

like image 284
deV Avatar asked Oct 25 '13 04:10

deV


1 Answers

The files you see when you do 'View Files' (IE options > General Tab > Settings > Temporary internet Files) are not actually files that are located on disc directly in the Temporary Internet Files folder.

There's a hidden folder inside that location called Content.IE5, and that will contain several randomly named folders with the actual temporary internet files inside them.

To get a list of them you can do this:

var path = Path.Combine(
    Environment.GetFolderPath(Environment.SpecialFolder.InternetCache),
    "Content.IE5");
string[] files = Directory.GetFiles(path, "*", SearchOption.AllDirectories);

For more information check out A Primer on Temporary Internet Files by Eric Law.

like image 65
Ergwun Avatar answered Nov 15 '22 11:11

Ergwun