I'm making an application that copies files from one location to another, in my application I use thread pool so a few copies could be done together. When I tried to copy a read only file I got "access denied" exception. In order to fix that I changed the file attributes to RW by using this command:
File.SetAttributes(fileName, File.getAttributes(fileName) & ~FileAttributes.ReadOnly);
The file attributes was changed successfully but the copy command:
File.Copy(fileName, destinationPath, true);
returned the same "access denied" exception.
When I run this applucation again on the same file, everything is run properly and the copy success because the file attributes was changed in the last running. My question is why the file wasn't copied in the first application running even I changed the attributes first and just then I tried to copy the file?