|
-
Jan 5th, 2009, 01:16 AM
#1
Thread Starter
Lively Member
[RESOLVED] [2008] How to Clear All Data In "Temporary Internet Files" Folder
I need to know How to Clear All Data In "Temporary Internet Files" Folder
Is there some code already made for that?
im having some trouble, and have no clue how to do it.
can someone please help me out.
thanks
-
Jan 5th, 2009, 01:42 AM
#2
Re: [2008] How to Clear All Data In "Temporary Internet Files" Folder
-
Jan 5th, 2009, 06:42 AM
#3
Re: [2008] How to Clear All Data In "Temporary Internet Files" Folder
You can use the SpecialFolder enum InternetCache like this to get the directory location:
vb Code:
Dim TempFiles() As String = IO.Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.InternetCache), "*.*")
Then just loop through and delete all of the files
-
Jan 5th, 2009, 05:51 PM
#4
Thread Starter
Lively Member
Re: [2008] How to Clear All Data In "Temporary Internet Files" Folder
 Originally Posted by chris128
You can use the SpecialFolder enum InternetCache like this to get the directory location:
vb Code:
Dim TempFiles() As String = IO.Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.InternetCache), "*.*")
Then just loop through and delete all of the files
how you do that and will this work for win xp
-
Jan 5th, 2009, 06:39 PM
#5
Re: [2008] How to Clear All Data In "Temporary Internet Files" Folder
I just told you how to do it and yes it should work fine with Windows XP - dee-u also gave you another solution that would work for Windows XP.
I'm not going to just do it for you, its simple enough to loop through some file paths and use something like My.Computer.FileSystem.DeleteFile to delete each one. If your not sure on how to do it just do a bit of reading up on how to do For loops or For Each loops
-
Jan 5th, 2009, 09:33 PM
#6
Lively Member
Re: [2008] How to Clear All Data In "Temporary Internet Files" Folder
 Originally Posted by chris128
I just told you how to do it and yes it should work fine with Windows XP - dee-u also gave you another solution that would work for Windows XP.
I'm not going to just do it for you, its simple enough to loop through some file paths and use something like My.Computer.FileSystem.DeleteFile to delete each one. If your not sure on how to do it just do a bit of reading up on how to do For loops or For Each loops
actually... the problem still arises when using a for each loop due to the fact that it's a special folder and a file.delete doesnt work. i watched it not work with my own eyes. why is it that everytime someone asks for help on here, it gets halfway provided and the person providing the "help" has to act like a jerk off?
-
Jan 5th, 2009, 09:51 PM
#7
Re: [2008] How to Clear All Data In "Temporary Internet Files" Folder
Did you look at the link I posted?
-
Jan 5th, 2009, 09:54 PM
#8
Thread Starter
Lively Member
Re: [2008] How to Clear All Data In "Temporary Internet Files" Folder
 Originally Posted by dee-u
Did you look at the link I posted?
the code in the link you provided works but a gay window comes up. is there a way to do this in the background?
-
Jan 5th, 2009, 10:12 PM
#9
Re: [2008] How to Clear All Data In "Temporary Internet Files" Folder
-
Jan 5th, 2009, 10:23 PM
#10
Thread Starter
Lively Member
Re: [2008] How to Clear All Data In "Temporary Internet Files" Folder
sorry i meant a window comes up showing its clearing the cookies/temporary files. is there a way to do this in the background without a window coming up?
the other guy provided a way to do it but i think since its a windows folder your not allowed to delete it just like that becaus its a special folder. Anyone know a working way to do this.
-
Jan 7th, 2009, 12:33 AM
#11
Thread Starter
Lively Member
Re: [2008] How to Clear All Data In "Temporary Internet Files" Folder
OK so I've been working on this for god knows how long now and still have no type of acceptable results. This is my current code:
Code:
Imports System.IO
Public Class Form1
Dim Count As Integer = 0
Private Sub ClearInternetCacheFolder()
ClearFolder(New DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.InternetCache)))
End Sub
Private Sub ClearFolder(ByVal directoryInfo As DirectoryInfo)
Try
For Each file As FileInfo In directoryInfo.GetFiles("*.*", SearchOption.AllDirectories)
Count += 1
'Debug.Print(Count & ". " & file.ToString)
file.Delete()
Next
For Each subfolder As DirectoryInfo In directoryInfo.GetDirectories("*", SearchOption.AllDirectories)
'Debug.Print("Folder: " & subfolder.ToString)
ClearFolder(subfolder)
Next
Catch ex As Exception
Debug.Print(ex.ToString)
End Try
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call ClearInternetCacheFolder()
End Sub
End Class
I am getting file exception errors while attempting to delete the files inside of the directories, and i also noticed that all of the files in the folder aren't being listed. Can someone please help me here... losing my f'ing mind. Thanks in advance.
Last edited by hazedoutdesi; Jan 7th, 2009 at 12:37 AM.
-
Jan 7th, 2009, 12:55 AM
#12
Re: [2008] How to Clear All Data In "Temporary Internet Files" Folder
All of your code can be replaced by this:
Code:
Directory.Delete( _
Environment.GetFolderPath(Environment.SpecialFolder.InternetCache), _
True _
)
-
Jan 7th, 2009, 01:39 AM
#13
Thread Starter
Lively Member
Re: [2008] How to Clear All Data In "Temporary Internet Files" Folder
And I get the same results with the code you provided as I was before (except for file listing since well... this doesnt list them)
"The process cannot access the file 'index.dat' because it is being used by another process."
Why is this like the hardest code to figure out? Has anyone done this successfully without using the method of
Code:
Process.Start("rundll32.exe", "InetCpl.cpl,ClearMyTracksByProcess 8")
-
Jan 7th, 2009, 02:25 AM
#14
Re: [2008] How to Clear All Data In "Temporary Internet Files" Folder
Could you try it like this?
Code:
Dim procID As Object
procID = Shell("RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8", AppWinStyle.Hide)
-
Jan 7th, 2009, 02:56 AM
#15
Re: [2008] How to Clear All Data In "Temporary Internet Files" Folder
Upon digging further you can instead use this to execute the process while not showing the window.
VB.Net Code:
Dim p As New Process()
p.StartInfo.FileName = "RunDll32.exe"
p.StartInfo.Arguments = "InetCpl.cpl,ClearMyTracksByProcess 8"
p.StartInfo.CreateNoWindow = True
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
p.Start()
-
Jan 7th, 2009, 08:06 PM
#16
Thread Starter
Lively Member
Re: [2008] How to Clear All Data In "Temporary Internet Files" Folder
 Originally Posted by dee-u
Upon digging further you can instead use this to execute the process while not showing the window.
VB.Net Code:
Dim p As New Process()
p.StartInfo.FileName = "RunDll32.exe"
p.StartInfo.Arguments = "InetCpl.cpl,ClearMyTracksByProcess 8"
p.StartInfo.CreateNoWindow = True
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
p.Start()
Thanks, your the man. i really appreciate it. this is what i was looking for.
-
Jan 7th, 2009, 08:41 PM
#17
Re: [2008] How to Clear All Data In "Temporary Internet Files" Folder
You can now mark your thread as Resolved by using the Thread Tools menu.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|