Results 1 to 17 of 17

Thread: [RESOLVED] [2008] How to Clear All Data In "Temporary Internet Files" Folder

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2006
    Posts
    108

    Resolved [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

  2. #2
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: [2008] How to Clear All Data In "Temporary Internet Files" Folder

    Will this help?
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  3. #3
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    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:
    1. Dim TempFiles() As String = IO.Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.InternetCache), "*.*")

    Then just loop through and delete all of the files
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  4. #4

    Thread Starter
    Lively Member
    Join Date
    Sep 2006
    Posts
    108

    Re: [2008] How to Clear All Data In "Temporary Internet Files" Folder

    Quote Originally Posted by chris128
    You can use the SpecialFolder enum InternetCache like this to get the directory location:
    vb Code:
    1. 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

  5. #5
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    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
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  6. #6
    Lively Member
    Join Date
    Jan 2007
    Posts
    96

    Re: [2008] How to Clear All Data In "Temporary Internet Files" Folder

    Quote 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?

  7. #7
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: [2008] How to Clear All Data In "Temporary Internet Files" Folder

    Did you look at the link I posted?
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Sep 2006
    Posts
    108

    Re: [2008] How to Clear All Data In "Temporary Internet Files" Folder

    Quote 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?

  9. #9
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: [2008] How to Clear All Data In "Temporary Internet Files" Folder

    What gay window?
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  10. #10

    Thread Starter
    Lively Member
    Join Date
    Sep 2006
    Posts
    108

    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.

  11. #11

    Thread Starter
    Lively Member
    Join Date
    Sep 2006
    Posts
    108

    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.

  12. #12
    Frenzied Member MaximilianMayrhofer's Avatar
    Join Date
    Aug 2007
    Location
    IM IN YR LOOP
    Posts
    2,001

    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 _
    )

  13. #13

    Thread Starter
    Lively Member
    Join Date
    Sep 2006
    Posts
    108

    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")

  14. #14
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    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)
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  15. #15
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    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:
    1. Dim p As New Process()
    2. p.StartInfo.FileName = "RunDll32.exe"
    3. p.StartInfo.Arguments = "InetCpl.cpl,ClearMyTracksByProcess 8"
    4. p.StartInfo.CreateNoWindow = True
    5. p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
    6. p.Start()
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  16. #16

    Thread Starter
    Lively Member
    Join Date
    Sep 2006
    Posts
    108

    Re: [2008] How to Clear All Data In "Temporary Internet Files" Folder

    Quote 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:
    1. Dim p As New Process()
    2. p.StartInfo.FileName = "RunDll32.exe"
    3. p.StartInfo.Arguments = "InetCpl.cpl,ClearMyTracksByProcess 8"
    4. p.StartInfo.CreateNoWindow = True
    5. p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
    6. p.Start()

    Thanks, your the man. i really appreciate it. this is what i was looking for.

  17. #17
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    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.
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width