# Reading modify change on file

**URL:** <https://discourse.nodered.org/t/reading-modify-change-on-file/33940>\
**Category:** General\
**Created:** [8 October 2020 13:32 UTC](https://discourse.nodered.org/t/reading-modify-change-on-file/33940 "2020-10-08T13:32:38Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ward](https://avatars.discourse-cdn.com/v4/letter/w/439d5e/32.png) [@Ward](https://discourse.nodered.org/u/Ward)\
**Post date:** [8 October 2020 13:32 UTC](https://discourse.nodered.org/t/reading-modify-change-on-file/33940/1 "2020-10-08T13:32:39Z")

</div>

Hi,

i'm using a watch node for checking if there are changes in file. This works if i open a file and save it's contents manually.  
But the problem lies with the fact when a siemens comfort panel is writing it's log over the ethernet to the file the file is overwritten but it's only changes it's modify date if i select the file(doesn't even have to open the file). So is there another way to read the modified time that's trigger the file?

Thanks at advance!  
Kind regards,  
Ward

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [8 October 2020 14:37 UTC](https://discourse.nodered.org/t/reading-modify-change-on-file/33940/2 "2020-10-08T14:37:17Z")

</div>

Why do you need the modified date to change?

---

<div class="post-metadata">

**Author:** ![Ward](https://avatars.discourse-cdn.com/v4/letter/w/439d5e/32.png) [@Ward](https://discourse.nodered.org/u/Ward)\
**Post date:** [8 October 2020 14:44 UTC](https://discourse.nodered.org/t/reading-modify-change-on-file/33940/3 "2020-10-08T14:44:43Z")

</div>

Every time the siemens panel writes a new alarm to the csv file i want node red to know. So i can load the file and read the last alarm.

And i thought the way to see if there is a change in the file you could do it with the date modified. And like i said it works but i have to select the file (not open just select the file in the folder so the data has been written) if the date will be updated. So to clarify it's not explained very well in the earlier post, but i meant is there a way to do what i do when i select the file to update the date. Not to overwrite the modified date.

Or would you take a different approach?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [8 October 2020 16:09 UTC](https://discourse.nodered.org/t/reading-modify-change-on-file/33940/4 "2020-10-08T16:09:23Z")

</div>

The Watch node should tell you every time it gets written to, whether the date changes or not. Is that not working?

If not then how is it being written over the network?

---

<div class="post-metadata">

**Author:** ![Ward](https://avatars.discourse-cdn.com/v4/letter/w/439d5e/32.png) [@Ward](https://discourse.nodered.org/u/Ward)\
**Post date:** [8 October 2020 16:16 UTC](https://discourse.nodered.org/t/reading-modify-change-on-file/33940/5 "2020-10-08T16:16:34Z")

</div>

That's indeed the strange thing about it. If there is a new alarm and i go look at the directory is see the old date. And no matter how long i wait i have to select it before it does a update of the time.

And a soon as the date is updated node red sees it. So node red is handling it fine, it's windows who don't update it automatically.

So that's why i wanted to know if there was another way?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [8 October 2020 16:26 UTC](https://discourse.nodered.org/t/reading-modify-change-on-file/33940/6 "2020-10-08T16:26:02Z")

</div>

You didn't reply to the question, how does it write to the file across the network?

---

<div class="post-metadata">

**Author:** ![Ward](https://avatars.discourse-cdn.com/v4/letter/w/439d5e/32.png) [@Ward](https://discourse.nodered.org/u/Ward)\
**Post date:** [8 October 2020 16:31 UTC](https://discourse.nodered.org/t/reading-modify-change-on-file/33940/7 "2020-10-08T16:31:10Z")

</div>

Srr forgot to write that.

I've got a shared folder on the PC where node red is installed. And the Siemens Comfort Panel write over the ethernet to that folder.

That works because if i call my alarm buffer on the comfort panel it's displaying them. And if i disconnect the panel from the ethernet, it can't find it's folder and don't display anything.

---

<div class="post-metadata">

**Author:** ![Ward](https://avatars.discourse-cdn.com/v4/letter/w/439d5e/32.png) [@Ward](https://discourse.nodered.org/u/Ward)\
**Post date:** [8 October 2020 16:35 UTC](https://discourse.nodered.org/t/reading-modify-change-on-file/33940/8 "2020-10-08T16:35:29Z")

</div>

And the protocol to the PC is ethernet/TCP/IP

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [8 October 2020 16:55 UTC](https://discourse.nodered.org/t/reading-modify-change-on-file/33940/9 "2020-10-08T16:55:51Z")

</div>

> [@Ward](#):
>
> I've got a shared folder on the PC where node red is installed

And that may be your problem. I would recommend reading up on filing system watches. Network shares in particular are a problem. You may need to write a polling flow.

---

<div class="post-metadata">

**Author:** ![Ward](https://avatars.discourse-cdn.com/v4/letter/w/439d5e/32.png) [@Ward](https://discourse.nodered.org/u/Ward)\
**Post date:** [8 October 2020 17:38 UTC](https://discourse.nodered.org/t/reading-modify-change-on-file/33940/10 "2020-10-08T17:38:20Z")

</div>

Oke will dive deeper into that topic. For the time being i start the flow every hour.

Thanks for the reply's

---

<div class="post-metadata">

**Author:** ![Nodi.Rubrum](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nodi.rubrum/32/107482_2.png) [@Nodi.Rubrum](https://discourse.nodered.org/u/Nodi.Rubrum)\
**Post date:** [8 October 2020 21:35 UTC](https://discourse.nodered.org/t/reading-modify-change-on-file/33940/11 "2020-10-08T21:35:22Z")

</div>

Can you grab the last accessed date (core to Windows API) of the file? Sometimes developers read the file before they write to it? So if last access date/time can give you a clue of when to poll for an update. Thus you would not have to poll 24/7 but only after the last accessed date/time changes? Just a thought.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [7 December 2020 21:35 UTC](https://discourse.nodered.org/t/reading-modify-change-on-file/33940/12 "2020-12-07T21:35:23Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
