I've got a folder in my PC that has 10 files. I have a routine that
presents the names of these files in a listbox (using a For ... Next
loop) in the order that they were created. The names are as follows:
Hi.htm
Raise.htm
Calls.htm
Netuse.htm
Contest.htm
Parking.htm
Internet.htm
Test.htm
Add.htm
JJ.htm
I've got a field in a SQL table that holds file names in the order
that they were entered. Their names are as follows:
Calls.htm
Contest.htm
Hi.htm
Netuse.htm
Raise.htm
Parking.htm
Internet.htm
Memos.htm
I'm supposed to run through these names and check against the file
names in the listbox within the loop. If there is a match, those
names are supposed to be deleted from the listbox so that only the
file names that aren't also in the SQL field stay in the listbox.
The code I have so far eliminates some, but not all, of the duplicate
file names. Here's my code:
Private Sub RevealFileNames()
Dim filePath As String = "C:\Inetpub\wwwroot\etc., etc."
Dim dInfo As New DirectoryInfo(filePath)
Dim fInfo As FileInfo() = dInfo.GetFiles
Dim i As Integer = 0
Dim strMemoToAdd As String = ""
Dim strMemoName As String = ""
For i = 0 To fInfo.Length - 1
'SQL query that looks for a record having the name
Dim objSQLMemoList As New SQLComponent()
objSQLMemoList.strConnection =
objConstants.DBConnectionString_Umove
objSQLMemoList.strSQL = "SELECT mgt_memoURL FROM
umv_memoManagement" 'pulling file name from umv_memoManagement table
objSQLMemoList.ExecuteSqlStatementAndReturnResults()
If objSQLMemoList.returnDataViewValue.Count > 0 Then
'adds file names from Memos folder only once after
checking if duplicate names are in umv_memoManagement
Dim intCounter As Integer = 0
If Trim(strMemoToAdd) <> Trim(strMemoName) Then
'adds each memo name to listbox & makes list
visible
lstMemos.Items.Add(Trim(fInfo(i).Name.ToString))
End If
intCounter += 1
strMemoToAdd = Trim(fInfo(i).Name.ToString)
strMemoName = Trim(objSQLMemoList.returnDataViewValue
(intCounter)("mgt_memoURL").ToString())
End If
Next
End Sub
Where in this code am I going wrong? Anyone?