views:

94

answers:

3

My Java program needs to delete any temporary internet files that were created by a "Shell.Explorer.1" ActiveX control created by the program.

What is the best way to do that?

If I go to Tools->Internet Options in Internet Explorer, click on the Browsing history Settings button on the General tab, and then click on the View files button, it takes me to this folder using Windows Explorer:

 C:\Documents and Settings\<user-name>\Local Settings\Temporary Internet Files

I then see a listing of "files", although I'm not sure they really are files. How do I delete these using Java?

However, when I call file.listFiles() where file is the directory listed above, I don't see any of the files I see in Windows Explorer. I see what I think are some hidden folders.

A: 

Windows treat the Temporary Internet Files folder (among others) differently than regular folders. You'd have to consult Windows documentation for the specifics, but as you've found out, the content of that folder as you see it in Windows Explorer does not match what your Java program finds.

You can use the command prompt to browse around the directory structure to see what your Java program would see (i.e. the hidden folders, etc). There's also a special index.dat file that may be helpful when you need to find files with certain properties.

See also: reverse engineering index.dat.

polygenelubricants
+1  A: 

Temporary Internet Files is a pretend folder. The view you see in Explorer is a combination of the actual files on disk, which live in securly unpredictably named subfolders, and the Wininet Url Cache Containers that store the metadata about the files (like what URL they came from, expiry date, etc). If you use filesystem APIs, you'll get what's actually there. If you use shell APIs, however, you can enumerate them in the way you want. Try starting with SHParseDisplayName() and go from there. And, yeah, dunno how to do it in Java, but there should be some way to call win32 functions from Java, right?

jeffamaphone
A: 

As others have said, Temporary Internet Files is a pseudo-folder, whose contents are managed by Internet Explorer / WinINet. As far as I know there is not any way to correlate which files were created by which programs (unless maybe you are looking for specific domains or last-modified dates). WinINet does provide some limited functionality for managing these files, but I think it is bad practice to go mucking around there. Why do you (think you) need to do this?

Luke