How to Get Last Shutdown Time using C#
<p>I have an application, that needs to get the last shutdown time. I have used EventLog class to get the shutdown time. I have separate class file that is designed to read/write event log. ReadPowerOffEvent function is intended to get the power off event.</p>

<pre><code>public void ReadPowerOffEvent()
    {
        EventLog eventLog = new EventLog();
        eventLog.Log = logName;
        eventLog.MachineName = machineName;

        if (eventLog.Entries.Count &gt; 0)
        {
            for (int i = eventLog.Entries.Count - 1; i &gt;= 0; i--)
            {
                EventLogEntry currentEntry = eventLog.Entries[i];

                if (currentEntry.InstanceId == 1074 &amp;&amp; currentEntry.Source=="USER32")
                {
                    this.timeGenerated = currentEntry.TimeGenerated;
                    this.message = currentEntry.Message;
                }
            }
        }
    }
</code></pre>

<p>But whenever it tries to get the event entry count, it throws an IOException saying "The Network Path Not found". I tried to resolve, but I failed. Please help me out...</p>
