csharp 简单的C#示例,用于连接Team Foundation Server存储库并从项目中下载文件。
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了csharp 简单的C#示例,用于连接Team Foundation Server存储库并从项目中下载文件。相关的知识,希望对你有一定的参考价值。
/*
In addition to standard imports, you need:
System.IO;
System.Net;
Microsoft.TeamFoundation.Client;
Microsoft.TeamFoundation.Framework.Common;
Microsoft.TeamFoundation.Framework.Client;
Microsoft.TeamFoundation.VersionControl.Client;
*/
string username = "memyselfandi";
string password = "mysecretpassword";
string repository = "https://example.visualstudio.com/DefaultCollection";
// Step 1: Obtain server via authenticated connection to project collection.
NetworkCredential nc = new NetworkCredential(username, password);
Uri uri = new Uri(repository);
TfsClientCredentials tfsCredential = new TfsClientCredentials(new BasicAuthCredential(nc));
tfsCredential.AllowInteractive = false;
TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(uri, tfsCredential);
tpc.Authenticate();
VersionControlServer vcs = tpc.GetService<VersionControlServer>();
// Step 2: Obtain item to be downloaded.
string projectName = "Top-level Folder";
string fileName = "ExampleFile.txt";
string itemPath = Path.Combine(projectName, fileName);
Item file = vcs.GetItems(String.Format(@"$/{0}", itemPath), RecursionType.None).Items.First<Item>();
// Step 3: Download item.
string destinationFolder = @"\Users\memyselfandi\Desktop";
using (Stream input = file.DownloadFile())
{
using (FileStream fout = File.Create(Path.Combine(destinationFolder, fileName)))
{
input.CopyTo(fout);
}
}
以上是关于csharp 简单的C#示例,用于连接Team Foundation Server存储库并从项目中下载文件。的主要内容,如果未能解决你的问题,请参考以下文章
神经网络,用于查找数字序列中的模式
Team Foundation Server (TFS)集成Flyway,实现数据库的版本管理
用于在头文件更改时构建简单 c 项目重新编译的示例 makefile
csharp 一个简单的C#示例,用于演示与MongoDB聚合结果交互的多态抽象类。
嵌套分组mysql
Week 1 # F Team Queue