I have an application that zips up some files and then attempts to send that in an e-mail as an attachment.
I have noticed that if the zip file is small it works fine (A few KB's), but the zip is generally between 1 and 2 MB's, and at that size (Which is still rather small) it fails. I get an error that it failed due to the target of an invocation.
I'm assuming that perhaps the zip file is not being released prior to the e-mail being generated when it's larger? I have both the zip creation and e-mail generation in their own backGroundWorkers.
I've been working on this for a good while now, and it doesn't seem to matter if my AntiVirus is running (I thought maybe it was trying to scan the zip), if I do a thread.Sleep, if I choose to send the mail upon the click of another button, etc. In fact, curiously, I created a test application that ONLY sends the zip file. This works perfectly. However, if I use my main application to create the zip file, this test application will be unable to send the zip until after the main application is closed. I really think that the file is not being released, but I don't know why, or from what. The backgroundWorker that is creating the zip is completing successfully (That is where I was originally calling the SendMail event).
My question is what the suggested course of action would be for doing something like this. I've never had an issue with accessing a file like this before.
I really appreciate any suggestions anyone may have for this. I can post whatever code you want, but there's a lot of it, so I'm not sure what all you would want.
Umm, read my answer again!
If you have something to add or contribute, feel free. Otherwise my point was that you apparently dont want faster updates... so you want slower updates by process of elimination.
If you have something to contribute, meaningful answers are better.
Question
M_Lyons10
Hello everyone.
I have an application that zips up some files and then attempts to send that in an e-mail as an attachment.
I have noticed that if the zip file is small it works fine (A few KB's), but the zip is generally between 1 and 2 MB's, and at that size (Which is still rather small) it fails. I get an error that it failed due to the target of an invocation.
I'm assuming that perhaps the zip file is not being released prior to the e-mail being generated when it's larger? I have both the zip creation and e-mail generation in their own backGroundWorkers.
I've been working on this for a good while now, and it doesn't seem to matter if my AntiVirus is running (I thought maybe it was trying to scan the zip), if I do a thread.Sleep, if I choose to send the mail upon the click of another button, etc. In fact, curiously, I created a test application that ONLY sends the zip file. This works perfectly. However, if I use my main application to create the zip file, this test application will be unable to send the zip until after the main application is closed. I really think that the file is not being released, but I don't know why, or from what. The backgroundWorker that is creating the zip is completing successfully (That is where I was originally calling the SendMail event).
My question is what the suggested course of action would be for doing something like this. I've never had an issue with accessing a file like this before.
I really appreciate any suggestions anyone may have for this. I can post whatever code you want, but there's a lot of it, so I'm not sure what all you would want.
Thanks Again,
Link to comment
https://www.neowin.net/forum/topic/846100-file-access-question-c/Share on other sites
11 answers to this question
Recommended Posts