How to remove a empty folder from a project under TFS control?

Visual Studio-2010Visual StudioTfs

Visual Studio-2010 Problem Overview


Suppose I have a project MyLib, under that, I created a folder say Folder1. No file under this folder. The project is connected to TFS.

Then I want to remove this folder Folder1. I deleted it from context menu and checked the project into TFS.

Then I check the data on TFS with Team Explore->Source Control, Folder1 is deleted. But it is still there in VS 2010 on local computer. I closed VS 2020 and deleted Folder1 from widows explore. Then open VS 2010 again, the Folder1 is still there. I can't remove it locally from MyLib!

Confused. How to resolve this problem?

Visual Studio-2010 Solutions


Solution 1 - Visual Studio-2010

Simply create a file within the folder and delete it along with the new file. TFS has some problems with empty folders when you try to delete them.

Solution 2 - Visual Studio-2010

Do the following:

  1. In Visual Studio, open "Solution Explorer".

  2. Right-click on the project in question, and select "Unload Project".

  3. Right-click on the unloaded project (should be grade out), and choose "Edit (Project)".

  4. In the XML Editor (that just opened) search for the problematic folder name (CTRL+F to bring up the "search" window, and search in current document for the folder name).

  5. When the search is done, it should highlight in the XML Editor the XML Node that contains the folder name (most of the times it is in a Node that tells Visual Studio to include the folder in question in the compilation of the project (via MSBuild)). Just delete the node that contains the name of the folder.

  6. Save changes, and close the Editor.

  7. Go back to Solution Explorer, right-click on the grayed-out project, and choose "Reload Project".

  8. Compile and check-in the project. Make sure you delete the physical folder from Windows Explorer (if it's still there).

Edit By Hakam Fostok: if your project under TFS, then after applying the previous steps you may need to open the Source Controler Explorer and delete the folder from there also

Solution 3 - Visual Studio-2010

If you right click on the project and select edit project file, you can then delete the entry for the offending folder. After you save and reload the project, you can then delete the folders from your hard drive and then source control.

Solution 4 - Visual Studio-2010

You can try doing Get Specific version. Right Click parent Folder of the file in Source Control and choose Get Specific version.It will open Get window, here choose Type as Latest Version and check the both available Check box options.

Solution 5 - Visual Studio-2010

Sorry for the late reply, I missed to check your reply.

The above error suggests that the folder may be Checked out & locked by some other user.

In Source Control, are you able to see the Status of the folder as Checkout & lock?

If yes,can you use Status Sidekick of TFS Sidekicks tool and try to unlock the folder (http://www.attrice.info/cm/tfs/).

Then, try to delete the folder again.

Solution 6 - Visual Studio-2010

I tried the solution that to add a new file then delete the folder with the file but failed.

My solution was to delete the physical folder first, then sign-in the code to TFS. (You will see the change list include the deletion of the folder.)

After sign-in, you will be able to delete the folder in your solution explorer.

Solution 7 - Visual Studio-2010

Just create a file in it (a class file for example) - check in, then after it checks in (successfully) - delete and it will do.

So simply put: check in and then delete and it will work..

Solution 8 - Visual Studio-2010

Here's what you do: Make a physical folder with the same name in the correct directory of your project. Check everything in. Once they get synched you'll be able to delete the folder from vs and check your program in again.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionKentZhouView Question on Stackoverflow
Solution 1 - Visual Studio-2010sraView Answer on Stackoverflow
Solution 2 - Visual Studio-2010Daniel WeiselView Answer on Stackoverflow
Solution 3 - Visual Studio-2010user588035View Answer on Stackoverflow
Solution 4 - Visual Studio-2010Jehan33View Answer on Stackoverflow
Solution 5 - Visual Studio-2010Jehan33View Answer on Stackoverflow
Solution 6 - Visual Studio-2010Alan FengView Answer on Stackoverflow
Solution 7 - Visual Studio-2010t_plusplusView Answer on Stackoverflow
Solution 8 - Visual Studio-2010MacMergView Answer on Stackoverflow