Search code examples
c#tfstfs-sdk

Read files from TFS Documents


I need to read files from TFS Documents. Someone know about api for this?

I tried this code, but I don't know what is the service interface for documents

 TfsTeamProjectCollection server = new TfsTeamProjectCollection(new Uri("http://xxx:8080/tfs"));

 VersionControlServer version = server.GetService(typeof(Docu)) as VersionControlServer;
 var items = version.GetItems(@"$\Development\Documents\Scenarios", RecursionType.None);

tfs documents

Thanks


Solution

  • The documents you are referring to: enter image description here

    Are actually on a SharePoint portal linked to your team project not in source control:

    You can share documents and files that you want to make available to all team members by uploading them to the project portal for your team project. You can create document libraries and organize the files that you upload to your project portal within those libraries, in addition to folders and subfolders. The folders and subfolders always appear in alphabetical order. (source)

    SharePoint document libraries can be accessed through the SharePoint API. See this question.

    There is no way to directly access the documents in the SharePoint document library using the TFS API. The only way around is not storing the documents you mention on in the SharePoint document library.

    For documents in TFS you have 3 options:

    • Store them as an attachment on a work item (retrieve via TFS WorkItemTracking API)
    • Store them as a versioned item in source control (retrieve via TFS VersionControl API)
    • Store them in the document library linked to your team project (retrieve via SharePoint API)

    This blog post compares these 3 options.