Hi again,
Im using vb 2005
Im using this code to watch a folder and log any changes etc... -
Imports System.IO
-
Imports System.Diagnostics
-
-
-
Public Class Form1
-
-
Public watchfolder As FileSystemWatcher
-
-
-
Private Sub btn_startwatch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_startwatch.Click
-
watchfolder = New System.IO.FileSystemWatcher()
-
-
'this is the path we want to monitor
-
watchfolder.Path = txt_watchpath.Text
-
-
'Add a list of Filter we want to specify
-
'make sure you use OR for each Filter as we need to
-
'all of those
-
-
watchfolder.NotifyFilter = IO.NotifyFilters.DirectoryName
-
watchfolder.NotifyFilter = watchfolder.NotifyFilter Or _
-
IO.NotifyFilters.FileName
-
watchfolder.NotifyFilter = watchfolder.NotifyFilter Or _
-
IO.NotifyFilters.Attributes
-
-
' add the handler to each event
-
AddHandler watchfolder.Changed, AddressOf logchange
-
AddHandler watchfolder.Created, AddressOf logchange
-
AddHandler watchfolder.Deleted, AddressOf logchange
-
-
' add the rename handler as the signature is different
-
AddHandler watchfolder.Renamed, AddressOf logrename
-
-
'Set this property to true to start watching
-
watchfolder.EnableRaisingEvents = True
-
-
btn_startwatch.Enabled = False
-
btn_stop.Enabled = True
-
-
'End of code for btn_start_click
-
-
End Sub
-
-
Private Sub logchange(ByVal source As Object, ByVal e As _
-
System.IO.FileSystemEventArgs)
-
If e.ChangeType = IO.WatcherChangeTypes.Changed Then
-
txt_folderactivity.Text &= "File " & e.FullPath & _
-
" has been modified" & vbCrLf
-
End If
-
If e.ChangeType = IO.WatcherChangeTypes.Created Then
-
txt_folderactivity.Text &= "File " & e.FullPath & _
-
" has been created" & vbCrLf
-
End If
-
If e.ChangeType = IO.WatcherChangeTypes.Deleted Then
-
txt_folderactivity.Text &= "File " & e.FullPath & _
-
" has been deleted" & vbCrLf
-
End If
-
End Sub
-
Public Sub logrename(ByVal source As Object, ByVal e As _
-
System.IO.RenamedEventArgs)
-
txt_folderactivity.Text &= "File" & e.OldName & _
-
" has been renamed to " & e.Name & vbCrLf
-
End Sub
-
-
Private Sub btn_stop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_stop.Click
-
' Stop watching the folder
-
watchfolder.EnableRaisingEvents = False
-
btn_startwatch.Enabled = True
-
btn_stop.Enabled = False
-
-
End Sub
-
End Class
-
-
I get this error: on line: 47 -
Cross-thread operation not valid: Control 'txt_folderactivity' accessed from a thread other than the thread it was created on.
-
Can anyone suggest anything, or tell me what this error means?
James
1 1490 -
System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = false
-
Made the problem go away.
James
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Web Science |
last post by:
Site and Features: http://www.eigensearch.com
Search engine, eigenMethod, eigenvector, mathematical, manifolds, science, technical, search tools, eigenmath, Jacobian, quantum, mechanics, manifolds, science, physics, chemistry, law, legal, government, home, office, business, domain lookup, medical, travel, food, university students, searching, searchers, surfing, advanced search, search tools
Chemistry, mathematics, physical sciences,...
|
by: * ProteanThread * |
last post by:
but depends upon the clique:
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=954drf%24oca%241%40agate.berkeley.edu&rnum=2&prev=/groups%3Fq%3D%2522cross%2Bposting%2Bversus%2Bmulti%2Bposting%2522%26ie%3DUTF-8%26oe%3DUTF-8%26hl%3Den
...
|
by: rollasoc |
last post by:
Hi,
Doing a bit of system testing on a Windows 98 laptop. (.Net 1.1 app).
Did a bit of testing. Loaded a previously saved file. A gray box
appeared with the text and buttons all white rectangles with a big red cross
in it. Pressed a button (the one I thought might be ok). My file
appeared to load. Then when I clicked on any button on my form, the button
was replaced with a white rectangle with a big red cross in it.
|
by: Web Science |
last post by:
Site and Features: http://www.eigensearch.com
Search engine, eigenMethod, eigenvector, mathematical, manifolds, science, technical, search tools, eigenmath, Jacobian, quantum, mechanics, manifolds, science, physics, chemistry, law, legal, government, home, office, business, domain lookup, medical, travel, food, university students, searching, searchers, surfing, advanced search, search tools
Chemistry, mathematics, physical sciences,...
|
by: David Peach |
last post by:
Hello, hope somebody here can help me... I have a query that lists
defects recorded in a user defined date range. That query is then used
as the source for a Cross Tab query that cross-tabs count of defect
type by calendar month. Defect types are stored in one table, defect
transactions in another along with date etc. When I cross-tab the
results, defect types that have no defects recorded against them
appear as a blank (null) value. That...
| |
by: Web Science |
last post by:
Site and Features: http://www.eigensearch.com
Search engine, eigenMethod, eigenvector, mathematical, manifolds, science, technical, search tools, eigenmath, Jacobian, quantum, mechanics, manifolds, science, physics, chemistry, law, legal, government, home, office, business, domain lookup, medical, travel, food, university students, searching, searchers, surfing, advanced search, search tools
Chemistry, mathematics, physical sciences,...
|
by: Rob Woodworth |
last post by:
Hi,
I'm having serious problems getting my report to work. I need to
generate a timesheet report which will contain info for one employee between
certain dates (one week's worth of dates). I have a table containing
records for each job done, the records contain date, employee name, job done
(a code representing the type of job), cost code (another code), regular
hours, and overtime hours. The tricky part is that more than one job can...
|
by: Simon |
last post by:
Hi All,
An experiment i'm doing requires requires a synchronous cross-domain
request, without using a proxy. I wondered if anyone had any ideas to
help me achieve this.
Below is what I have tried, including my conclusions/assumptions
(which i'll happily be corrected on if it solves my problem!):
The requirement not to use a proxy means I can't use the synchronous
|
by: Bart Van der Donck |
last post by:
Hello,
I'm presenting my new library 'AJAX Cross Domain' - a javascript
extension that allows to perform cross-domain AJAX requests.
http://www.ajax-cross-domain.com/
Any comments or suggestions are welcome.
--
|
by: ampo |
last post by:
Hello.
Can anyone help with cross-domain problem?
I have HTML page from server1 that send xmlHTTPRequest to server2.
How can I do it?
Thanks.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |