FILE INFO.

How can I add only files that already exits and file that just created in Listbox? I have set Timer on this sub.

Dim XDir As DirectoryInfo = New DirectoryInfo(Trim("" & Me.txtPathX.Text & ""))

Dim ExtraCount As Integer

Dim myfileInfo as fileinfo

For Each myfileInfo In XDir.GetFiles

ExtraCount = XDir.GetFiles.Length

Me.lblCountExtra.Text = ExtraCount.ToString

Me.ListBox2.Items.Add(myfileInfo.CreationTime)  -------------------- This line just keepS adding the same file(Time it is created) over and over



Next

If ExtraCount = Nothing Then

Me.lblCountExtra.Text = CStr(0)

End If
VBdotnet2005Asked:
Who is Participating?
 
armoghanCommented:
What I have understood is that you need a directory watcher

http://www.codeproject.com/dotnet/folderwatcher.asp
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Can you explain in plain english what the code is ~supposed~ to accomplish?   =)
0
 
armoghanCommented:
or
look for FileSystemWatcher class in MSDN
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
VBdotnet2005Author Commented:
Idle_Mind ,

I want to add a file name and time in a folder to a list box when a new file is added and keep track of how many item in a list box. FileSystemWatcher class?
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Yes...I think armoghan was right on with the FileSystemWatcher.
0
 
VBdotnet2005Author Commented:
thank you
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.