サーバーのディスクにファイルが存在するかどうかを確認したいのですが、次のコードを使用しています
if (File.Exists(Server.MapPath("~/Jaram Images/") + Path.GetFileName(product.Pic_Url2)))
                                            {
                                                WriteError("File  exist!");
                                                //PdfProdCell = new PdfPCell(iTextSharp.text.Image.GetInstance(Server.MapPath("~/Jaram Images/") + Path.GetFileName(product.Pic_Url2)), true);
                                            }
                                            else
                                                WriteError(Server.MapPath("~/Jaram Images/") + " File doesn't exist!");
しかし、私はこのエラーが発生しています:
public static void WriteError(string errorMessage)
{
    try
    {
        string path = "~/Jaram PDF/PDFS/" + DateTime.Today.ToString("dd-mm-yy") + ".txt";
        if (!File.Exists(System.Web.HttpContext.Current.Server.MapPath(path)))
        {
            File.Create(System.Web.HttpContext.Current.Server.MapPath(path)).Close();
        }
        using (StreamWriter w = File.AppendText(System.Web.HttpContext.Current.Server.MapPath(path)))
        {
            w.WriteLine("\r\nLog Entry : ");
            w.WriteLine("{0}", DateTime.Now.ToString(CultureInfo.InvariantCulture));
            string err = "Error in: " + System.Web.HttpContext.Current.Request.Url.ToString() +
                          ". Error Message:" + errorMessage;
            w.WriteLine(err);
            w.WriteLine("__________________________");
            w.Flush();
            w.Close();
        }
    }
    catch (Exception ex)
    {
        WriteError(ex.Message);
    }
}
Log Entry : 
05/03/2012 15:50:51
Error in: http://localhost/WebStore/AdminNewAccount.aspx?role=+Administrator. Error Message:C:\inetpub\wwwroot\WebStore\Jaram Images\ File doesn't exist!
私のログ関数はこれが好きです