473,383 Members | 1,803 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

How to check only one dir in filesystemwatch

I try to monitor a directory for new created files that in this example
shall be moved to another dir. So far it looks like working as it should but
after the first file (one file copied into the dir) it detect a new file
created and go trough the routine again.
I have turned off the IncludeSubdirectories but it still do it

The code is the following

Imports System.IO

Public Class frmFileWatcher

Inherits System.Windows.Forms.Form

Private WithEvents fsWatchObj As FileSystemWatcher

Dim DispMessage As Boolean

Private Sub SetupWatcher(ByVal PathToWatch As String)

fsWatchObj = New FileSystemWatcher(PathToWatch)

fsWatchObj.IncludeSubdirectories = False ' True

fsWatchObj.EnableRaisingEvents = True

fsWatchObj.NotifyFilter = fsWatchObj.NotifyFilter Or _

IO.NotifyFilters.FileName

fsWatchObj.NotifyFilter = fsWatchObj.NotifyFilter Or _

IO.NotifyFilters.LastWrite

AddHandler fsWatchObj.Created, New FileSystemEventHandler(AddressOf
Me.FileCreated)

End Sub

Private Sub FileCreated(ByVal s As System.Object, ByVal EventInfo As
FileSystemEventArgs)

Dim DisplayMessage As String

If (EventInfo.ChangeType = WatcherChangeTypes.Created) Then

DisplayMessage = "File " & EventInfo.Name & " was "

DisplayMessage &= EventInfo.ChangeType.ToString & " at " &
DateTime.Now.ToString

MsgBox(DisplayMessage)

lstFiles.Items.Add(DisplayMessage)

FileCopy(EventInfo.FullPath, "e:\resizer\ut\" & EventInfo.Name)

End If

End Sub

Private Sub FileRenamed(ByVal s As System.Object, ByVal EventInfo As
RenamedEventArgs)

Dim DisplayMessage As String

DisplayMessage = "File " & EventInfo.OldName

DisplayMessage &= " was renamed " & EventInfo.Name & " at " &
DateTime.Now.ToString

lstFiles.Items.Add(DisplayMessage)

End Sub

Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnStart.Click

If txtDirToWatch.Text = "" Then

MessageBox.Show("Please enter path to watch", "Enter Path",
MessageBoxButtons.OK, MessageBoxIcon.Warning)

Else

Call SetupWatcher(txtDirToWatch.Text)

End If

End Sub

End Class

Petter L.
Jul 21 '05 #1
0 1140

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: Craig Bailey | last post by:
Someone please explain what alternate universe I fell into this afternoon when PHP started telling me that 2 doesn't equal 2. Not sure about you, but when I run this, it tells me 59001.31 doesn't...
13
by: Adrian Parker | last post by:
I have a PHP generated page which displays X many records. Each record has a checkbox preceding it. The user checks several checkboxes, and hits a delete button. All the corresponding records...
17
by: Dave Smithz | last post by:
Hi there, A PHP application I built has a section which lists a number of members to a club whose names each appear with a check box beside them that can be ticked. These check boxes are part...
7
by: Tony Johnson | last post by:
Can you make a check box very big? It seems like when you drag it bigger the little check is still the same size. Thank you, *** Sent via Developersdex http://www.developersdex.com ***...
2
by: Travis.Box | last post by:
I have an MS Access userform with 16 Check Boxes. Each of the checkboxes has a different option value, which coincides with the Check Box name (eg. cb01.OptionValue = 1). At the bottom of the...
1
by: scprosportsman | last post by:
Please help guys, i am trying to set up a database here at work and im fairly new to access in terms of writing functions and queries and stuff. I have 2 different places on my design that will...
2
by: Chris Davoli | last post by:
How do you enable a check box in the GridView. I selected Checkbox Field in the Columns of the GridView, and the check box shows up in the Grid view, but it is disabled. How do I enable it so I can...
16
by: Brian Tkatch | last post by:
Is there a way to check the order in which SET INTEGRITY needs to be applied? This would be for a script with a dynamic list of TABLEs. B.
5
by: starke1120 | last post by:
Im creating a check in – check out database for RF guns. I have a table that contains models. ID (primary key) Model A table that contains Gun Details ID (primary key) Model_id...
1
by: ghjk | last post by:
my php page has 7 check boxes. I stored checked values to database and retrive as binary values. This is the result array Array ( => 0 => 1 => 0 => 1 => 0 => 0 => 1 ) 1 means checked....
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.