From 31f580d3d61f198995809fa38f006555401e0e73 Mon Sep 17 00:00:00 2001 From: rpm-mcarman <65228808+rpm-mcarman@users.noreply.github.com> Date: Mon, 23 Jan 2023 11:10:16 -0500 Subject: [PATCH] Modified Executing Directory 3rd attempt --- Program.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Program.cs b/Program.cs index 0467e15..15f3765 100644 --- a/Program.cs +++ b/Program.cs @@ -90,7 +90,8 @@ namespace jdis_import list.Add(todo); //Download File FileAttachment fAttachment = attachment as FileAttachment; - File.WriteAllBytes(fAttachment.Name, fAttachment.Content); + string fileAttachmentPath = Path.Combine(_exeDir, fAttachment.FileName); + File.WriteAllBytes(fileAttachmentPath, fAttachment.Content); msg.IsRead = true; } } @@ -116,7 +117,7 @@ namespace jdis_import else { body = string.Format(body, sendMsg.FileName, sendMsg.WorkOrder, string.Format("Had Errors while importing: {0}", sendMsg.Validation)); - msgToSend.Attachments.AddFileAttachment(sendMsg.FileName); + msgToSend.Attachments.AddFileAttachment(Path.Combine(_exeDir, sendMsg.FileName) } @@ -125,8 +126,9 @@ namespace jdis_import msgToSend.CcRecipients.Add(new EmailAddress("mcarman@rpmindustries.com")); msgToSend.Body = body; msgToSend.SendAndSaveCopy(); - if (sendMsg.Success) File.Move(sendMsg.FileName, Path.Combine("Success", sendMsg.FileName)); - else File.Move(sendMsg.FileName, Path.Combine("Fail", sendMsg.FileName)); + string pathToFile = Path.Combine(_exeDir, sendMsg.FileName); + if (sendMsg.Success) File.Move(pathToFile, Path.Combine(_exeDir, "Success", sendMsg.FileName)); + else File.Move(sendMsg.FileName, Path.Combine(_exeDir, "Fail", sendMsg.FileName)); } } catch (MsalException ex)