Getting dir() to work correctly

wilso132
01-26-2004, 09:45 AM
I'm basically trying to make a program that will go into the server where I work and delete the cookies.

Basically, each cookie folder will look like this:
D:\Profiles\FirstName.LastName\Cookies

As you can see by my code, I set up test files on my computer. The problem I'm having is, when it reaches the last dir() call to actually move to the next Profile (FirstName.LastName), it says I must call dir() using a pathname... which I already defined before the while loop.

Any help would be GREATLY appreciated (especially since I'm new to VB and .NET).

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strFolderName, strCookieName, strTXTCheck As String
strFolderName = Dir("C:\Test\", FileAttribute.Directory)
While (strFolderName <> "")
strCookieName = Dir("C:\Test\" + strFolderName + "\", FileAttribute.Directory)
While (strCookieName <> "")
If (strCookieName = "Cookies") Then
strTXTCheck = Dir("C:\Test\" + strFolderName + "\Cookies\*.txt")
If (strTXTCheck <> "") Then
Kill("C:\Test\" + strFolderName + "\Cookies\*.txt")
End If
End If
strCookieName = Dir()
MsgBox("Just changed cookie dir to " + strCookieName, MsgBoxStyle.OKOnly, "Test")
End While
MsgBox("Above last dir", MsgBoxStyle.OKOnly, "Test")
strFolderName = Dir()
MsgBox("Below last dir", MsgBoxStyle.OKOnly, "Test")
End While
End Sub

Iceplug
01-26-2004, 11:54 AM
It'd probably be simpler if you took the .NET road and used System.IO.Directory.GetFiles. You can read them into an array and then add a counter into the loop to access a part of the array. :)

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum