ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help with FileSystemWatcher in .NET

Solved!
Go to solution

Since I haven't been too familiar with .NET in any language, I'd figure I'd start out with something simple like the FileSystemWatcher. I was wondering if anyone had any experience with the this constructor. How do I make .NET trigger when a file has changed?

 

I went by the example on the MSDN site for this, but I've hit a snag. Can anyone help? I've included the VI below.

 

FSW.png

0 Kudos
Message 1 of 5
(6,051 Views)
Solution
Accepted by Eric1977

Hi Eric,

 

why don't you study the ready-to-use example in the LabVIEW community?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 5
(6,042 Views)

I wrote a version of soemthing like this once.

 

The thing to keep in mind is that different applications read and write to files in different ways.

 

I found Notepad generated multiple events for a single save. Not very friendly 😞

 

Another FileSystemWatcher example can be found here:

 

http://blog.jki.net/labs/dont-throw-away-your-throw-away-code/

 

 

 

0 Kudos
Message 3 of 5
(6,018 Views)

@GerdW wrote:

Hi Eric,

 

why don't you study the ready-to-use example in the LabVIEW community?


I didn't see that on my Google search. Probably just skimmed right over it. Thanks.

0 Kudos
Message 4 of 5
(5,991 Views)

@Eric1977 wrote:

Since I haven't been too familiar with .NET in any language, I'd figure I'd start out with something simple like the FileSystemWatcher. I was wondering if anyone had any experience with the this constructor. How do I make .NET trigger when a file has changed?


Callbacks are never simple! 😁 LabVIEW tries to hide away some of the complications but only manages in a limited way to do that. It's definitely not straightforward programming and in a way goes completely against LabVIEW dataflow programming, which is why they chose to implement it as an event in .Net. Unfortunately .Net events don't map easily to LabVIEW events.

 

Whenever I had to deal with events in .Net or Java code in the past I always had to pinch myself a few times to get my mind wrapped around the correct syntax and not make a total mess of the implementation.

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 5 of 5
(3,738 Views)