Help with deleting files...

Kris Jacyna

Member
Joined
Feb 12, 2007
Messages
20
Programming Experience
Beginner
I am writing a program which deletes all files in my temporary internet files folder.
Is the best way to go about this using the Kill statement?

Greatful for any help,

Kris Jacyna
 
VB.NET:
Dim Acc As String = "C:\Documents and Settings\Admin\"
If Directory.Exists(Acc & IO.Path.DirectorySeparatorChar & "Local Settings\Temporary Internet Files") = True Then Call ClearDir(Acc & IO.Path.DirectorySeparatorChar & "Local Settings\Temporary Internet Files")
VB.NET:
    Private Sub ClearDir(ByVal Dir As String)
        Dim strFiles() As String = Directory.GetFiles(Dir)
        For Each strFile As String In strFiles
            Try
                File.Delete(strFile)
            Catch
            End Try
        Next strFile
        Dim strDirs() As String = Directory.GetDirectories(Dir)
        For Each strDir As String In strDirs
            Try
                Call ClearDir(strDir)
                Directory.Delete(strDir, False) ', True)
            Catch
            End Try
        Next strDir
    End Sub

I've actually got a class that deletes a bunch of temp crap in windows xp using threading
 
JuggaloBrotha, it is a system cache, you can't clear it through filesystem as I know of. I tried the code but it didn't clear the cache. Btw, you can get those specialfolders easier and more accurate like this:
VB.NET:
Dim ipt As String = Environment.GetFolderPath(Environment.SpecialFolder.InternetCache)
 
JuggaloBrotha, it is a system cache, you can't clear it through filesystem as I know of. I tried the code but it didn't clear the cache. Btw, you can get those specialfolders easier and more accurate like this:
VB.NET:
Dim ipt As String = Environment.GetFolderPath(Environment.SpecialFolder.InternetCache)

did not know that, i'll have to incorporate those changes
 
Back
Top