From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

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
(4,396 Views)
Solution
Accepted by topic author 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
(4,387 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/

 

 

 


Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
If you don't hate time zones, you're not a real programmer.

"You are what you don't automate"
Inplaceness is synonymous with insidiousness

0 Kudos
Message 3 of 5
(4,363 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
(4,336 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
0 Kudos
Message 5 of 5
(2,083 Views)