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


If ExtraCount = Nothing Then

Me.lblCountExtra.Text = CStr(0)

End If
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mike TomlinsonHigh School Computer Science, Computer Applications, and Mathematics TeachersCommented:
Can you explain in plain english what the code is ~supposed~ to accomplish?   =)
What I have understood is that you need a directory watcher

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
look for FileSystemWatcher class in MSDN
Angular Fundamentals

Learn the fundamentals of Angular 2, a JavaScript framework for developing dynamic single page applications.

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?
Mike TomlinsonHigh School Computer Science, Computer Applications, and Mathematics TeachersCommented:
Yes...I think armoghan was right on with the FileSystemWatcher.
VBdotnet2005Author Commented:
thank you
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.