130

When checking in my project I get the error:

Could not find file 'C\blah blah blah'.

I have a feeling this might be a file from an old project I deleted.

I have tried deleting my TFS connection and workspaces.

jessehouwing
  • 106,458
  • 22
  • 256
  • 341
user1438082
  • 2,740
  • 10
  • 48
  • 82
  • 1
    I had a similar error from having moved files in my work space. Resolved by removing the work space and creating a new one, then doing a get. – Thronk Aug 04 '14 at 17:47

5 Answers5

301

This will happen when TFS has some changes staged that no longer exist on the file system. For instance, if you add some files in Visual Studio (which adds them to the changes list), delete them directly from the file system, then attempt to check in the changes, it will complain that it could not find the file(s).

To remove these changes from the list, you can open Source Control Explorer (View > Other Windows > Source Control Explorer) and either Delete the nonexistent files or right-click on the offending files and Undo Pending Changes.

You can also undo these specific changes from the Pending Changes panel in Team Explorer.

jessehouwing
  • 106,458
  • 22
  • 256
  • 341
doingweb
  • 3,608
  • 2
  • 18
  • 12
  • 6
    Thanks for the great tip! I had a project that was deleted, but it was still showed in the Source Control Explorer. I could not find any way to delete directly from the Source Control Explorer. I right-clicked the project, then selected "Undo Pending Changes...", and it disappeared magically! I never expected that "undo pending changes" would remove the entire folder. TFS is unique in this regard. – Hong Apr 09 '14 at 04:13
  • 4
    Surely this should be the accepted answer. Much simpler than having to create a dummy file and then delete it. Especially when in my case I had over 1000 files that needed to be removed! – Iain Carlin Dec 04 '14 at 23:38
  • 2
    @doingweb provided a better answer. You can fix this warning via TFS, without manual file manipulation. After adding a new Project and deleting an old Project from a Solution, I had a similar error. My fix: 1. Exclude the old project and (any related files with this warning) from check-in. 2. Check in your changes. 3. With Source Control Explorer, find the project you intend to delete. It's probably checked out. 4. Undo changes on that project. 5. Delete that old project. 6. Check in changes. – Ken Palmer Dec 30 '14 at 21:36
  • 1
    This has also happened to me when I create a project of the wrong type (e.g., a console app instead of a test project), remove the project and then add a project of the same name with the correct type - all before I've checked anything in (i.e., it's a virgin solution). Either way, this is a good fix. – ftexperts Feb 13 '15 at 21:15
  • 1
    This is still an issue in 2017...this is idiotic. What the user intends is perfectly inferrable (he changed his mind and deleted in-between check-ins) and worst case could be handled by a confirmation dialog... – Chris B. Behrens Sep 11 '17 at 15:10
  • Great answer. In my case, I created the same project 5 or 6 times testing out different VS project templates. Orphaned references to files from those deleted projects kinda got stuck in source control limbo, which wouldn't allow me to check in my project. Undo pending changes successfully cleared all the old cruft out. – cowsay Apr 18 '18 at 14:24
  • does anyone know how to conduct this automatically on TFS server? https://stackoverflow.com/questions/54599856/tfs-server-checkin-error-could-not-find-file-server-related-and-command-line –  Feb 16 '19 at 03:26
27

Create an empty file to replace the missing file and complete your check-in. After you have checked in the file correctly delete the file that is not needed.

Marko
  • 2,734
  • 24
  • 24
  • 1
    Done - Now how do i delete them "properly" – user1438082 Sep 11 '13 at 20:50
  • 12
    Delete the files by going into source control explorer in visual studio, find the files and right click delete. Check in the changes so the delete is persisted on the server. There are many helpful videos on youtube that can help with common source control tasks. – Marko Sep 11 '13 at 20:52
  • done - why do the folders still show-up grayed out in source control explorer - i want them gone forever. – user1438082 Sep 11 '13 at 20:56
  • 1
    Read up on the "destroy" functionality in TFS. This will make the files/folders gone forever. – xcodr Sep 12 '13 at 23:59
  • 1
    This works, but if you deleted a directory that had dozens of files, then it might be a bit tedious. – James Parsons Dec 21 '17 at 13:46
  • 1
    Does anyone know how to conduct this on TFS server? https://stackoverflow.com/questions/54599856/tfs-server-checkin-error-could-not-find-file-server-related-and-command-line –  Feb 16 '19 at 03:26
9

Go to the project that has file 'blah blah blah', you should see the file has an error mark indicating it does not exist. Right click the file > Delete. That should take care of the problem.

Hong
  • 17,643
  • 21
  • 81
  • 142
3

I had a similar problem. I had forgotten I was tinkering with adding publish profiles for publish. TFS felt it needed to check that in, even though the output wasn't there. I simply right clicked on the App.Publish folder in Team Explorer inside of visual studio and chose to exclude. Checked everything back in with no problem.

Rudy Hinojosa
  • 1,448
  • 14
  • 15
-1

I encountered the same error: enter image description here

but my issue was a bit different. I was changing a couple of folder names and when committing I didn't add the new folders to the repo:

git add folderName

solved the issue for me.

dier
  • 2,791
  • 2
  • 15
  • 8
  • Downvoted. This is a question about TFS specifically, and you've answered with an answer about git, an entirely different piece of software. – Eleanor Holley Sep 11 '20 at 18:39