I´ve written some code to send files as attachments of .eml files with C#.
I create the files in an Windows temp folder and attach them to a .eml file.
The .eml files are simply opened and send through Process.Start(filename);
with the standard mailing program in windows. If the users wishes to send the file again, the file will be rewritten from the database to make sure its the newest version.
Now to my problem: Randomly a few times or after just the first time I rewrite the file the error appears
The process cannot access the file because it is being used by another process
I acutally did some research on the web and found this other question.
So I made sure like mentioned there, that the FileStream is set correctly with all arguments.var fs = new FileStream(tempPathSave, FileMode.Open, FileAccess.Write, FileShare.ReadWrite)
Has someone an idea what is the reason for my problem? My biggest problem is, that I can´t really duplicate it to say it is happening when I do this or that.
EDIT: I am using the FileStream in an using statement to make sure that it is disposed right.