To Get Folder List under Team Project
-
Thursday, August 09, 2012 1:10 PMHow to get Folder List and there name which are under teamproject and also to get the list of project name which are under particular solution under teamproject of TFS.
- Moved by Trevor HancockMicrosoft Employee, Moderator Thursday, August 16, 2012 4:19 PM More to do with TFS VC than build. Moving. (From:Team Foundation Server - Build Automation)
All Replies
-
Friday, August 10, 2012 8:52 AMModerator
Hi Dileep,
Thanks for your post!
Do you mean you want to get the folder list and and the project list under particular solution under Source Control Explorer?
If yes, it can be implement using TFS API. In the following blog, which starts of how to use VersionControlServer class in TFS API to map the Source Control. Please refer to http://blogs.microsoft.co.il/blogs/shair/archive/2009/02/26/tfs-api-part-16-mapping-source-control-using-versioncontrolserver.aspx
Hope it helps!
Best Regards,
Cathy Kong [MSFT]
MSDN Community Support | Feedback to us
- Marked As Answer by Dileep Chopra Tuesday, August 21, 2012 10:25 AM
-
Friday, August 10, 2012 1:22 PM
Thanks for reply
I have seen the code where it is getting checkin details and from there it splite and store.Actually i am looking to get data from the TFS server directly folder name.
Thanks!
-
Tuesday, August 14, 2012 6:13 AMModerator
Hi Dileep,
Thanks for your post!
Do you mean you want to get the source control explorer folder structure?
Best Regards,
Cathy Kong [MSFT]
MSDN Community Support | Feedback to us
-
Tuesday, August 14, 2012 8:54 AM
Yes
For Example : I have folder name sampleapplication under which i have 5 project i want to get folder name and the list of project name under that folder.
i.e; folder name : sampleapplication
Project Name : project1
project2
project3
project4
project5
Thanks!
-
Thursday, August 16, 2012 6:35 AMModerator
Hi Dileep,
Thanks for your post!
I am trying to involve someone familiar with this topic to further look at this issue. There might be some tiem delay. Appreciate your patience.
Thank you for your understanding and support.
Best Regards,
Cathy Kong [MSFT]
MSDN Community Support | Feedback to us
-
Monday, August 20, 2012 3:28 PMOwner
Hi Dileep,
What version of TFS are you using?
Looks like you can use the ListAllProjects method (http://msdn.microsoft.com/en-us/library/tfs/microsoft.teamfoundation.integration.server.classification.listallprojects(v=vs.110).aspx) .See these examples:
http://social.msdn.microsoft.com/Forums/en-US/tfsgeneral/thread/beec6503-2a0d-4b46-94f0-b169a1fd671a
http://phacker.wordpress.com/2010/11/05/list-all-tfs-project-collections-and-projects/
See the ListAllProjects example to display projects in this link:
http://www.devx.com/dotnet/Article/40739/1954
Thanks!
Trevor Hancock (Microsoft)
Please remember to "Mark As Answer" the replies that help. -
Tuesday, August 21, 2012 10:25 AM
Thanks for reply!
My question is how to get the list of folder name under team project.i don't want the list of team project the above code will give the list of team project.
Thanks!
-
Tuesday, August 21, 2012 9:41 PMOwner
Cathy's reply has already provided an answer for this I think. If you want to programmatically get a list of folders (projects, solutions, etc.) in TFS Source Control, that blog post and the sample code associated with it will do what you want:
You will need to re-work the sample to fit your specific needs of course, but it should provide a good starting point.
If this does not address your specific request, please try once more to explain exactly what you want, and include a screen shot if you can.
Trevor Hancock (Microsoft)
Please remember to "Mark As Answer" the replies that help.- Marked As Answer by Trevor HancockMicrosoft Employee, Moderator Tuesday, August 28, 2012 5:53 PM
-
Tuesday, September 04, 2012 5:23 AM
The following code will help to get the folder Name :
ICommonStructureService structureService = (ICommonStructureService)Tfscollection.GetService(typeof(ICommonStructureService));
ProjectInfo[] projects = structureService.ListAllProjects();
//combo_projects.ItemsSource = projects;
////Create VersionControlServer object from TFS
//sourceControl = (VersionControlServer)tfs.GetService(typeof(VersionControlServer));
RecursionType recursion = RecursionType.OneLevel;
Item[] items = null;
string path = "$/" + projects[0].Name;//"$/TescoPOC/FetchStoryfromTFS";
ItemSet itemSet = versionControl.GetItems(path, recursion);
items = itemSet.Items;
//Dictionary<string, int> FolderListName = new Dictionary<string, int>();
List<string> FolderListName = new List<string>();
foreach (Item keyItem in items)
{
char[] charSeparators = new char[] { '/' };
//Using split to isolated the Project Name and the File Name
string[] ss = keyItem.ServerItem.Split(charSeparators, StringSplitOptions.None);
if (keyItem != items[0])
{
string filename = keyItem.ServerItem.Replace(path + "/", string.Empty);
if (filename != "BuildProcessTemplates")
{
FolderListName.Add(filename);
//if (FolderListName.ContainsKey(filename))
// FolderListName[filename] = FolderListName[filename] + 1;
//else
// FolderListName.Add(filename, 1);
}
}
}Regards!
Dileep Chopra.
- Marked As Answer by Dileep Chopra Tuesday, September 04, 2012 5:23 AM

