Build Error-Could not write lines to file FileListAbsolute.txt. Access to the path is denied.

If you are receiving below error while building your solution using TFS build.

Build error

Possible reason for this error could be that when the first time the project was build and failed it left Read-Only file in the obj or bin folder or it has duplicate files with same name.

There are multiple solutions to this issue, whichever works for you is good.

  1. You can change the property of the FileListAbsolute.txt or any other file that is giving permission denied error and make it writable.
  2. You can delete the obj( also bin folder if only deleting obj folder didn’t work) folder from your local drive and TFS source control. Check in the changes. And do a Clean and Build.

2nd solution resolved my issue though.