We help IT Professionals succeed at work.

FILE INFO.

VBdotnet2005
VBdotnet2005 asked
on
Medium Priority
191 Views
Last Modified: 2011-04-14
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
Comment
Watch Question

Mike TomlinsonHigh School Computer Science, Computer Applications, Digital Design, and Mathematics Teacher
CERTIFIED EXPERT
Top Expert 2009

Commented:
Can you explain in plain english what the code is ~supposed~ to accomplish?   =)
Commented:
What I have understood is that you need a directory watcher

http://www.codeproject.com/dotnet/folderwatcher.asp

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Commented:
or
look for FileSystemWatcher class in MSDN

Author

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, Digital Design, and Mathematics Teacher
CERTIFIED EXPERT
Top Expert 2009

Commented:
Yes...I think armoghan was right on with the FileSystemWatcher.

Author

Commented:
thank you
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.