I have a small application that uploads, copies and then logs the actions to a text file. I have my functions enclosed in try/catch statements, but the application seems to still move, copy the files and write to the log even if the upload was unsuccessful. Could this be happening because of my catch statements? How can I makle sure that the application stops (writes to the log that it is stopping) if the upload was unsuccessful?
Code:
static void Main(string[] args)
{
string GroupEmail = "myemail@abc.com";
sendEmail confirmMail = new sendEmail();
Program prg = new Program();
try
{
prg.UploadEdi();
}
catch(Exception uplErr)
{
confirmMail.send("<font face='arial' size='2'>Error Uploading File(s)</font><br>" + uplErr.ToString(), GroupEmail, "Unsuccessful File Upload to Server", "0");
}
try
{
prg.WriteToStream();
}
catch (Exception StreamErr)
{
confirmMail.send("<font face='arial' size='2'>Error Sending File</font><br>" + StreamErr.ToString(), GroupEmail, "Unsuccessful Log", "0");
}
try
{
prg.MoveEdi();
}
catch (Exception movErr)
{
confirmMail.send("Unsuccessful file move to destination folder" + movErr.ToString(), GroupEmail, "Unsuccessful Move", "0");
}
}