title: StreamWriter not writing to file when called from task Scheduler C#
body: <p>I have the following function, that accepts a string, and logs the string content to a log file. </p>
  
  <pre><code>private static void LogEvent(string sEvent)
  {
          sEvent = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + "|" + sEvent;
  
          Console.WriteLine(sEvent);
  
          try
          {
              using (StreamWriter oStreamWriter = new System.IO.StreamWriter("MyService_" + DateTime.Now.ToString("yyyyMMdd") + ".log", true))
              {
                  oStreamWriter.WriteLine(sEvent);
              }
          }
          catch
          {
  
          }
  }
  </code></pre>
  
  <p>When the program calling the function is manually run from the command line or by double clicking executable, the log file is either created or appended to.  </p>
  
  <p>The problem I have is I've set this program to be called from a task scheduler every 10 minutes, and for some reason the code is executing correctly, except the program is not creating or appending to the log file.</p>
  
  <p>The scheduled task is calling the program using the same user permissions as when I manually ran the program.</p>
  
  <p>Why is this happening, and how can I fix it.</p>