• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 176
  • Last Modified:

waiting for file creation

Hi,
I've to waiting for a file in a directory.
I explain better:
my program has to waiting that a file will be created in a directory,
so my program have to continue.
How can I do it in Vb.net without Timer object?
and without the code below witch fill all the CPU?
filename=dir(path)
while filename<>""
filename=dir()
end while

Open in new window

0
bobdylan75
Asked:
bobdylan75
  • 4
  • 2
1 Solution
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Your code snippet doesn't tell us which environment you are actually working in...

You using classic VB6 (or below) or VB.Net?  (you have multiple zones selected)
0
 
bobdylan75Author Commented:
VB.NET..
if you read slowly, you note that in the 2nd line from the bottom..
I wrote "how can I do it in Vb.net"
;-)
thanks
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Haha...gotcha.  =)

You're looking for the FileSystemWatcher component then:
http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.aspx

0
NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

 
Mike TomlinsonMiddle School Assistant TeacherCommented:
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
The below code and image show how to be notified when "c:\someFile.txt" is created:
Public Class Form1
 
    Private Sub FileSystemWatcher1_Created(ByVal sender As Object, ByVal e As System.IO.FileSystemEventArgs) Handles FileSystemWatcher1.Created
        MessageBox.Show("c:\someFile.txt Created!")
    End Sub
 
End Class

Open in new window

FileSystemWatcherProperties.jpg
0
 
bobdylan75Author Commented:
Wow! Very interesting! thank you very much
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now