Directory not found exception
<p>I am trying to write an error log which will store down all errors into a .txt file.
But right now, the problem im facing is "Directory Not Found Exception"</p>

<p>Below is my code for my common method (writelog)</p>

<pre><code>using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using System.IO;
using System.Diagnostics;

/// &lt;summary&gt;
/// Summary description for Writelog
/// &lt;/summary&gt;
/// &lt;param name="ErrorDesc"&gt;Desc&lt;/param&gt;
/// &lt;param name="ID"&gt;ID&lt;/param&gt;
/// &lt;param name="ProgPage"&gt;Name&lt;/param&gt;
/// &lt;param name="Message"&gt;Error Message&lt;/param&gt;
public class Writelog
{
    public static void WritelogDesc(string Desc, string ID, string Name, string ErrorMessage)
    {
        StringBuilder sBuilder = new StringBuilder();

    string Errorlog = System.Configuration.ConfigurationManager.AppSettings["Errorlog"];

    string path = System.AppDomain.CurrentDomain.BaseDirectory.ToString();

    sBuilder.Append(DateTime.Now.ToString("dd/MM/yyyy") + " " + DateTime.Now.ToShortTimeString());
    sBuilder.Append(" | ");
    sBuilder.Append(Desc);
    sBuilder.Append(" | ");
    sBuilder.Append(ID);
    sBuilder.Append(" | ");
    sBuilder.Append(Name);
    sBuilder.Append(" | ");
    sBuilder.Append(ErrorMessage);

    StreamWriter sw = (!File.Exists(path)) ? File.CreateText(path) : File.AppendText(path);
    sw.WriteLine(sBuilder.ToString());
}
</code></pre>

<p>}</p>

<p>And here is how i call the writelog.</p>

<pre><code> Writelog.WritelogDesc("Desc", "ID", "Name", "ErrorMessage");
</code></pre>
