Hello,
I am stuck with this problem....
I have few folders that contains a filename as registration.txt --- note the folder names are different since as and when a new user will register a folder gets created with its name and then the text file with the details of the user....
I have to read the user id from the text files to the Listbox and then check if any user id has been repeated in the list box....(stuck here)
I have able to read the data but just not able to perform the check on the id...
Please someone help me in this
See the code below what I tried....
Imports System.IO
Public Class Form3
Dim filename As String
Private Sub Form3_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Dim di As New IO.DirectoryInfo("D:\UserDetails\") '----folder where all the user data is saved
Dim diar1 As IO.DirectoryInfo() = di.GetDirectories()
Dim dra As IO.DirectoryInfo
Dim sr As StreamReader
Dim line As String
Dim Fields() As String
Dim lines As String()
For Each dra In diar1
Dim filename1 As FileInfo = New FileInfo(di.ToString + dra.ToString + "\UserRegEntry.txt")
If filename1.Exists Then
filename = di.ToString + dra.ToString + "\UserRegEntry.txt"
sr = New StreamReader(filename)
line = sr.ReadLine()
If line <> String.Empty Then
lines = IO.File.ReadAllLines(filename)
Fields = line.Split("*") '---* is the delimiter
ListBox1.Items.Add(dra.ToString + "----------" + Fields(0)) '---just to read the User ID
Else
ListBox3.Items.Add(dra.ToString)
End If
Else
ListBox2.Items.Add(dra.ToString)
End If
Next
Label1.Text = ListBox1.Items.Count.ToString + " UserRegEntry.txt files found"
Label2.Text = ListBox2.Items.Count.ToString + " UserRegEntry.txt files not found"
Label3.Text = ListBox3.Items.Count.ToString + " No data in txt file"
End Sub
End Class