mardi 21 août 2018

C# If else program not recognizing the if statement and only taking the else

Hi i have the following code, the problem i am facing is no matter if the folder exists it still continues to send the email instead of ignoring to send it.

What can i change to get this working.

    static void Main(string[] args)
    {
        string yesterdaydate = DateTime.Now.AddDays(-1).ToString("yyyy-mm-dd");
        string[] SplitDate = yesterdaydate.Split('-');
        string year = SplitDate[0];
        string month = SplitDate[1];
        string day = SplitDate[2];
        string path = Path.Combine("C:\\Users\\ales\\Desktop\\test", year, month, day);

        if (Directory.Exists(path))
        {
            //do nothing
        }

        else
        {
            string fromAddress = "noreply@arm.com";
            string toAddress = "alese@arm.com";
            string subject = "error";
            string body = "failed to sync";

            krysalis_email.EmailClient email = new krysalis_email.EmailClient();
            krysalis_email.EmailClient.EmailResponse emailResponse = email.sendBasicMail(new object[] {toAddress}, fromAddress, subject, body, false, "smtp.za.arm.com",
                new string[] {"", ""}, false, null);


            if (emailResponse != null)
            {

            }

        }

    }

Aucun commentaire:

Enregistrer un commentaire