I'm trying to use the following code to delete a read-only file.
var fileInfo = new FileInfo(saveLocation);
fileInfo.IsReadOnly = false;
fileInfo.Delete();
When it gets to the third line, the following exception is thrown
Message: The process cannot access the file '\\filepath\filename.pdf' because it is being used by another process.
Note: \\filepath\filename.pdf is not the actual file path, I'm just using it to replace a longer path
I've checked the file, and before the code runs, it is set to read-only, and after the code runs, it is not anymore.
Am I incorrect in thinking that when a file is opened as read-only it is not considered to by in use? I'm pretty sure that is true for Microsoft office files suck as .xlsx files, but maybe not for PDFs?
Ultimately, my goal is to be able to push an updated version of this file to a shared location even if some user has the file open on their machine, which is why I initially set it to be read-only.