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

x
?
Solved

Internet Cache Returns Wrong Directory

Posted on 2009-02-16
3
Medium Priority
?
292 Views
Last Modified: 2012-05-06
Hi,

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)
  {
    myDirectoryInfo.Create();
  }
 
  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);
    File.Delete(myCache);
  }
 
  //Delete the directory.
  myDirectoryInfo.Delete(true);
  HttpContext.Current.Response.Write(myCache_1);
}

Open in new window

0
Comment
Question by:tedporter
  • 2
3 Comments
 
LVL 29

Accepted Solution

by:
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?

0
 

Author Closing Comment

by:tedporter
ID: 31547360
Hi,

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.
0
 
LVL 29

Expert Comment

by:fibo
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
0

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