-
Notifications
You must be signed in to change notification settings - Fork 69
Open
Description
Hi!
Contrary to the needs of most users, I need RoboCommand to block until the copy completes. This is due to the fact that I send the RoboCopy.log file via email once the copy completes. If I add the attachment to the email before the RoboCopy operation completes, I get an exception that the file is in use. I would expect RoboCommand.Start to block until the external process is complete unless implemented with async/await. This does not seem to be the case. Is this a bug, or am I missing something?
Here is a simplified version of my method:
public void BackItUp()
{
// Create a list to act as the RoboQueue
List<RoboCommand> myRoboQueue = new List<RoboCommand>();
// Add commands to the RoboQueue
for (int i = 0; i < sourceDirs.Count; i++)
{
var sourceDir = sourceDirs[i];
var destinationDir = destinationDirs[i];
// Define and add RoboCommand instances to the queue
RoboCommand command = new RoboCommand();
// Log Options
if (i == 0)
{
command.LoggingOptions.LogPath = logPath;
}
else
{
command.LoggingOptions.AppendLogPath = logPath;
}
// Add the command to the queue
myRoboQueue.Add(command);
}
// Process the queue
foreach (RoboCommand command in myRoboQueue)
{
// Execute the RoboCommand
command.Start();
}
//Send RoboCopy log file via email
mail.Attachments.Add(new Attachment(logPath));
// Send the EMail
try
{
smtpClient.Send(mail);
logger.LogMessage("RoboCopy Backup: Email sent successfully!", "RoboSharp Test", MSGLEVEL_INFO);
}
catch (Exception ex)
{
logger.LogMessage("Error sending email: " + ex.Message, "RoboSharp Test", MSGLEVEL_WARNING);
}
logger.LogMessage("RoboCopy Backup Complete!", "RoboSharp Test", MSGLEVEL_INFO);
}
Metadata
Metadata
Assignees
Labels
No labels