I am receiving the following error sporadically and rarely:
Access to the path 'e:\Batch\CR\data_Test\IM_0232\rdlcTemp\RN837102.ZM\MemberEOB_1.pdf' is denied.
The exact block of code where the error occurs is shown below. This error only occurs sporadically and rarely. If we reboot the server and try to run the same input file again, we will find that the error does not occur again - but not always. This code is in a loop which can be executed up to 5000 times in a single run of the application. We find the error can occur at any point in the run - 100s of PDF files will be created without any problem and then this error will occur. Why are we getting this error?
Relevant code:
byte[] bytes = report.Render("PDF", deviceInfo);
FileStream fs = new FileStream(@savePath + ".pdf", FileMode.Create);
fs.Write(bytes, 0, bytes.Length);
fs.Close();
fs.Dispose();