windows application can not write to log.txt
<p>This is main program.cs</p>

<pre><code>LogError.WriteError("Application started: " + DateTime.Now + Environment.NewLine);
            try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new CrawlerApp());
            }
            catch (Exception e)
            {
                LogError.WriteError(e);
            }
            LogError.WriteError("Application closed: " + DateTime.Now + Environment.NewLine);
</code></pre>

<p>and this is LogError class</p>

<pre><code>public static class LogError
    {
        public static void WriteError(Exception e)
        {
            WriteError("Message: " + e.Message + Environment.NewLine + "Stack trace: " + e.StackTrace);
        }

        public static void WriteError(string error)
        {
            try
            {
                StreamWriter sw = File.AppendText("log.txt");
                sw.WriteLine(DateTime.Now + Environment.NewLine);
                sw.WriteLine(error + Environment.NewLine);
                sw.WriteLine(Environment.NewLine);
                sw.Close();
            }
            catch (Exception)
            {
                //
            }
        }
    }
</code></pre>

<p>When i publish application and run it log.txt file is never created. If i run application from bin/debug folder then works. Why when i publish app logging not working. I am using win 2003 OS.</p>
