Link to home
Start Free TrialLog in
Avatar of beaconlightboy
beaconlightboy

asked on

vb.net FileInfo not listing correctly

I wrote some code that simple cleans out a users temporary internet cache, however it does not want to list out on the console all the files in the directory.  However if i change the directory to non hidden directory it works fine.  any ideas?  obviously username is in place of a username i would type in during testing.
My.Application.DoEvents()
        Dim DSPath As String = "C:\Documents and settings\username\local settings\temporary internet files"
        'Dim DSPath As String = "C:\Documents and Settings\" & GetUsername(My.User.Name) & "\Local Settings\Temporary Internet Files"
        Dim DS As New System.IO.DirectoryInfo(DSPath)
        Dim FI As System.IO.FileInfo

        Console.WriteLine(FIA.Length)
        For Each FI In DS.GetFiles
            Me.TBStatus.Text = "Cleaning Cookies: " & FI.FullName
            Console.WriteLine(FI.FullName)
        Next

Open in new window

Avatar of Jarrod
Jarrod
Flag of South Africa image

try this:
Dim dir As String = "C:\Documents and settings\username\local settings\temporary internet files\"
        If Directory.Exists(dir) Then
            Directory.Delete(dir & "*.*", True)
        End If

Open in new window

Avatar of beaconlightboy
beaconlightboy

ASKER

Ok but i don't want to delete the directory, and that doesn't explain why the code doesn't show the directory listing when i select that directory as opposed to others.
The code will not delete the root directory. Use directory.getfiles(path) to show the contents, the way u are doing it filters out hidden objects
huh, nice of them to tell you that in the documentation.  i will try it.
Cool
Cool
ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial