documentBuilder: The process cannot access the file because it is being used by another process
- by st mnmn
I am using DocumentBuilder (of openXML api), to those who doesn't know the documentBuilder I'll give a short explanation: it has a function 'BuildDocument' which gets list of sources (each source contains wmldocument), and string of fileName to save to.
public static void BuildDocument(List<Source> sources, string fileName)
the purpose of this function is to build one word docx which contains all the sources. it merges some docs to one.
at the end of its functionality it saves the doc using:
File.WriteAllBytes(...)
but when I run my project on the server I keep getting the error: "The process cannot access the file because it is being used by another process."
few times it works ok. and in the visualStudio it also works without errors.
what can be the problem?