I can't write on file 'Filename.pdf'
I had the same problem. If you use Adobe Acrobat reader X, go to the Preferences of Acrobat Reader. In the menu Security (Enhanced) deselect Protection and Protection Enhanced OR add the Folder Path of your pdf folder build with latex.
That's work with me !
I know this is not the answer to your question, but i sometimes also get that error.
If you work with a cloud drive such as Google drive or Dropbox you often run into problems because the cloud started syncing before writing to all the files is done.
The bigger your tex file, the longer it takes to compile, the bigger your chances to encounter this type of error
A solution (If that is the problem) would be to stop the syncing with the cloud for the period of compiling.
I found the problem thanks to https://www.overleaf.com. I created an account an pasted my code and it resulted with an error in a tikz figure, I forgot to put an semicolon, " ; ", in the end of a line which caused the program to not compile which also resulted in errors in other tex files that were not related to the one with the error. Many thanks to a friend on facebook who responded to my post on facebook about this problem.