TFS secondary development-baseline File Manager (3)-source code file reading

Source: Internet
Author: User

After logging on to TFS, you can start to read the source code directory tree.

In general, I do not recommend that you read the entire tree, because there are not only project files, but also project source code. If you read all the data, it will be a very big tree. Therefore, we recommend that you read only the root directory. Each time you click to open a level-1 subdirectory. In this way, you can find the file you want to select.

In the previous section, we have logged on.

 

// Obtain the selected project name. Here is a single project, and the PI [0] Name Pi = TPP is obtained at one time. selectedprojects; projecturl = PI [0]. name; versioncontrolserver version = server. getservice (typeof (versioncontrolserver) as versioncontrolserver; // obtain the project's first-level file directory itemset items = version. getitems (@ "$ \" + projecturl, recursiontype. onelevel );

 

 

Next, we will build the first-level directory tree of the project. The retrieved item is a directory containing the parent node, so you need to remove it before adding

// Clear the treeview1.nodes tree first. clear (); // obtain the parent node item subitem = items. items [0]; string mainsub = subitem. serveritem; foreach (item in items. items) {// remove the parent node if (mainsub = item. serveritem) {} else {treenode tnadd = new treenode (item. serveritem); tnadd. name = item. serveritem; treeview1.nodes. add (item. serveritem, item. serveritem );}}

 

The following figure shows the effect after execution. There are two levels of directories under the project.

 

Next we will create a click event for the tree. Recursively add subnodes to the clicked node.

/// <Summary> /// handle the event after the node is selected /// </Summary> /// <Param name = "sender"> </param> /// <Param name = "E"> </param> private void treeview1_aftercheck (Object sender, treevieweventargs e) {If (E. action! = Treeviewaction. unknown) {version = server. getservice (typeof (versioncontrolserver) as versioncontrolserver; itemset items = version. getitems (E. node. text, recursiontype. onelevel); foreach (item in items. items) {If (E. node. TEXT = item. serveritem) {} else {// here, the name is used to store the Changeset version ID and the text storage display path E. node. nodes. add (item. serveritem, item. serveritem, item. changesetid);} e. node. expand ();}}}

 

 

The final effect is as follows.

TFS secondary development-baseline File Manager (3)-source code file reading

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.