I have an SSIS package where I am generating a file and sending it to a user, that works all well. however, they want the date in the file name, and I don't want to have a bunch of old daily files sitting in my directory, so I try to delete the file after sending (all of this is done is a script task).
System.IO.File.Delete(DestinationName);
Now, the problem is, I get an error saying it can't delete because the file is in use by another process (the sending of the email) so I thought to make it wait a bit:
//wait a minute before deleting
System.Threading.Thread.Sleep(60000);
System.IO.File.Delete(DestinationName);
By this time I have recieved the email, however, the process is still holding on to the file. How do I get the email to let go? Do i need to put this in its own Script Task?
Thanks