Search This Blog

August 3, 2012

How to search the file name in Temporary Internet Files folder in C#?

Yesterday, I tried to validate one scenario: if users launch Silverlight UI, how much time does it take to download the files (1 xap file and 19 zip files) in their Temporary Internet Files folder?

Temporary Internet Files folder is the virtual folder. The .xap file is not really inside that folder.




From the command prompt, I can know what the file path is for my Sprint2.xap. It has 2 sub folders. Besides, zip files are not in the same sub folder.

..\Microsoft\Windows\Temporary Internet Files\Content.IE5\L0BLXHLN\Sprint2[1].xap (2 sub folders)




In this situation, how do I search the file names in Temporary Internet Files folder in C#?

After doing some research, I can use the following code easily to get any file name I want in Temporary Internet Files folder.

string filePath = Environment.GetFolderPath(Environment.SpecialFolder.InternetCache);

var files = Directory.GetFiles(filePath, "filename*”, SearchOption.AllDirectories); //filename=Sprint2

If I can validate all files are in in Temporary Internet Files, it means I download them from our server successfully.

No comments: