title: Exporting application event logs
body: <p>I ran into a problem when exporting windows application event logs. I used code from msdn. </p>
  
  <pre><code>try
        {
            EventLogSession els = new EventLogSession();
            els.ExportLogAndMessages("Application", PathType.LogName, "*", 
                Path.Combine(temporaryDirectory, "ApplicationLogs.evtx"), false, 
                   CultureInfo.CurrentCulture);
        }
              catch (UnauthorizedAccessException e)
              {
                  MessageBox.Show("Unauthorized access to event logs. "+e.Message);
              }
              catch (EventLogNotFoundException e)
              {
                  MessageBox.Show("Event logs not found. "+e.Message);
              }
              catch (EventLogException e)
              {
                  MessageBox.Show("Event log exception. "+e.Message);
              }
  </code></pre>
  
  <p>When I start the program, the code runs fine on my computer. However when used on some different computers I sometimes get exception  "Event log exception. The directory name is invalid". The evtx file is exported correctly, however the LocaleMetadata folder that contains .MTA file is not present and the exception is thrown. I've tried searching the internet for solution but couldn't find any. The exported log file is to be viewed on different computer so my understanding is that I need the metadata file exported as well. How can I ensure that the locale metadata folder is always exported alongside evtx file without throwing said exception?</p>