gpt4 book ai didi

c# - 如何以编程方式从 sourcesafe 获取文件?

转载 作者:行者123 更新时间:2023-11-30 13:21:31 25 4
gpt4 key购买 nike

我需要以编程方式从 sourcesafe 数据库中获取文件。知道怎么做吗?

ps:我将使用 C# 来完成。

最佳答案

using System;
using System.Collections.Generic;
using SourceSafeTypeLib;

namespace YourNamespace
{

public class SourceSafeDatabase
{
private readonly string dbPath;
private readonly string password;
private readonly string rootProject;
private readonly string username;
private readonly VSSDatabaseClass vssDatabase;

public SourceSafeDatabase(string dbPath, string username, string password, string rootProject)
{
this.dbPath = dbPath;
this.username = username;
this.password = password;
this.rootProject = rootProject;

vssDatabase = new VSSDatabaseClass();
}

public List<string> GetAllLabels()
{
List<string> allLabels = new List<string>();

VSSItem item = vssDatabase.get_VSSItem(rootProject, false);
IVSSVersions versions = item.get_Versions(0);

foreach (IVSSVersion version in versions)
{
if (version.Label.Length > 0)
{
allLabels.Add(version.Label);
}
}

return allLabels;
}

public void GetLabelledVersion(string label, string project, string directory)
{
string outDir = directory;
vssDatabase.get_VSSItem(rootProject, false).get_Version(label).Get(ref outDir, (int)VSSFlags.VSSFLAG_RECURSYES + (int)VSSFlags.VSSFLAG_USERRONO);
}

public void Open()
{
vssDatabase.Open(dbPath, username, password);
}

public void Close()
{
vssDatabase.Close();
}

}


// some other code that uses it

SourceSafeDatabase sourceControlDatabase = new sourceControlDatabase(...);
sourceControlDatabase.Open();
sourceControlDatabase.GetLabelledVersion(label, rootProject, projectDirectory);
sourceControlDatabase.Close();

关于c# - 如何以编程方式从 sourcesafe 获取文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/286713/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com