<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Best way to check if a file exists]]></title><description><![CDATA[<p dir="auto">Hi,<br />
I want to raise an alarm in case an outdated Office dll exists.<br />
The path of the file is<br />
C:\Program Files (x86)\Common Files\microsoft shared\OFFICE11\mso.dll</p>
<p dir="auto">At the moment I use this File.Count DCI:<br />
File.Count("C:\Program Files (x86)\Common Files\microsoft shared\OFFICE11","mso.dll",0,0)</p>
<p dir="auto">As long as the OFFICE11 folder exists this works fine, but if the folder doesn't exist it returns an error.</p>
<p dir="auto">I can't count recursive from  \microsoft shared\  for mso.dll as there is a OFFICE16 folder below it containing a mso.dll as well.</p>
<p dir="auto">Regards</p>
<p dir="auto">Stefan</p>
]]></description><link>https://forum.netxms.org/topic/7562/best-way-to-check-if-a-file-exists</link><generator>RSS for Node</generator><lastBuildDate>Fri, 13 Nov 2026 21:54:10 GMT</lastBuildDate><atom:link href="https://forum.netxms.org/topic/7562.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 16 Nov 2022 11:29:34 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Best way to check if a file exists on Mon, 21 Nov 2022 08:12:01 GMT]]></title><description><![CDATA[<p dir="auto">For version 4.3 we have also added new metric File.Type, which returns 0 if file does not exist, 1 if it is a directory, 2 if it is a device, and 3 if it is a regular file.</p>
<p dir="auto">Best regards,<br />
Victor</p>
]]></description><link>https://forum.netxms.org/post/32042</link><guid isPermaLink="true">https://forum.netxms.org/post/32042</guid><dc:creator><![CDATA[victor]]></dc:creator><pubDate>Mon, 21 Nov 2022 08:12:01 GMT</pubDate></item><item><title><![CDATA[Reply to Best way to check if a file exists on Wed, 16 Nov 2022 12:36:20 GMT]]></title><description><![CDATA[<p dir="auto">You can make script DCI and process errors inside the script, e.g.:</p>
<pre><code>s = $node-&gt;readAgentParameter("File.Size(/tmp/1/1.txt)");
if (s != NULL) return 1; else return 0;
</code></pre>
<p dir="auto">s != NULL condition can be actually simplified:</p>
<pre><code>s = $node-&gt;readAgentParameter("File.Size(/tmp/1/1.txt)");
if (s) return 1; else return 0;
</code></pre>
<p dir="auto">I've used File.Size, as it is simpler and has just one parameter, but you can use File.Count as well.</p>
<p dir="auto">P.S. Instead of script DCI you can use internal DCI with metric "Dummy" and have all the scripting in transformation script.</p>
]]></description><link>https://forum.netxms.org/post/32032</link><guid isPermaLink="true">https://forum.netxms.org/post/32032</guid><dc:creator><![CDATA[Filipp Sudanov]]></dc:creator><pubDate>Wed, 16 Nov 2022 12:36:20 GMT</pubDate></item></channel></rss>