Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Internet Cache Returns Wrong Directory

Posted on 2009-02-16
Medium Priority
Last Modified: 2012-05-06

I am trying to clear the Tempoary Internet Files from my PC using C#. I have manually checked where they are sitting which is "C:\Documents and Settings\EPorter\Local Settings\Temporary Internet Files".

However, my code is returning "C:\Documents and Settings\EGP\ASPNET\Local Settings\Temporary Internet Files ", where EGP is the name of my PC.

Not sure what is going on but could do with some help please - thanks.
public void ClearIECache()
  DirectoryInfo myDirectoryInfo = new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.InternetCache));
  if (myDirectoryInfo.Exists == false)
  string myCache_1 = myDirectoryInfo.FullName;
  string[] myChache_2;
  File.SetAttributes(myCache_1, FileAttributes.Normal);
  myChache_2 = System.IO.Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.InternetCache));
  //Get all files in Temporary internet
  foreach (string myCache in myChache_2)
    //files, folder and then set their attribute to normal then delete
    File.SetAttributes(myCache, FileAttributes.Normal);
  //Delete the directory.

Open in new window

Question by:tedporter
  • 2
LVL 29

Accepted Solution

fibo earned 2000 total points
ID: 23650890
Both answers / addresses are correct, although they relate to different uses...

Your C# program uses "its" cache under ASPNET...
Not sure that the security option will allow this program to access "your" cache...

In fact this is probably forbidden (or this is a safety hole):
Imagine that the C# program is running on a remote server... would it be OK for it to access files on your machine?


Author Closing Comment

ID: 31547360

I have tested both locally (XP) and remotley (Server 2003) on IIS and your definition is correct. Oh well, back to the drawing board!

Thanks for you help.
LVL 29

Expert Comment

ID: 23667502
B-)) Glad it helped, thx for the grade and points.
B-( Sorry for the bad news that your initial plan will not work

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s a strangely common occurrence that when you send someone their login details for a system, they can’t get in. This article will help you understand why it happens, and what you can do about it.
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…
Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question