Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从c#代码写入VSS中的文件?_C#_Visual Sourcesafe - Fatal编程技术网

如何从c#代码写入VSS中的文件?

如何从c#代码写入VSS中的文件?,c#,visual-sourcesafe,C#,Visual Sourcesafe,我有一个使用Visual Source Safe(VSS)的项目,需要在“.sql”文件中追加行。 我试图使用明显的代码: using (StreamWriter sw = File.AppendText(lblSourceFile.Text)) { sw.WriteLine("text here"); } 但我收到“文件访问”错误,因为文件未在VSS中签出。 是否有一种方法可以通过编程签出文件进行编辑,并在完成后将其签回? 我找到的所有链接都使用VSSDatabaseClass,我不

我有一个使用Visual Source Safe(VSS)的项目,需要在“.sql”文件中追加行。 我试图使用明显的代码:

using (StreamWriter sw = File.AppendText(lblSourceFile.Text))
{
    sw.WriteLine("text here");
}
但我收到“文件访问”错误,因为文件未在VSS中签出。 是否有一种方法可以通过编程签出文件进行编辑,并在完成后将其签回?
我找到的所有链接都使用VSSDatabaseClass,我不知道如何添加对SourceSafetypelib dll的引用并使用VSSDatabaseClass…

您可以添加ssapi.dll作为引用,它可以在VSS的安装文件夹中找到,然后您可以使用SourceSafetypelib。您可以看到一个示例。

感谢Rachel提供了ssapi.dll文件。 以下是适用于我的系统的代码:

 using SourceSafeTypeLib;
 VSSDatabaseClass vssDatabase = new VSSDatabaseClass();
 vssDatabase.Open("VSS database path", "userName", "password");
 VSSItem item = vssDatabase.get_VSSItem("file path as shown in vss", false);
 item.Checkout("Comments", item.LocalSpec, 0);
 using (StreamWriter sw = File.AppendText(lblSourceFile.Text))
 {
     sw.WriteLine("text");
 }
 item.Checkin("Comments", item.LocalSpec, 0);
 vssDatabase.Close();

据我记忆所及,应该有这样的命令行工具:我在那里找不到我需要的东西…你需要签出文件还是使其可写?我需要在其中写入一些东西,所以签出它可能是必须的,除非你知道我如何在不签出文件的情况下写入。你能告诉我ctor参数是从哪里来的吗
SourceSafeDatabase sourceControlDatabase=newsourcesafedatabase(“dbPath”、“用户名”、“密码”、“根项目”)
我有我的用户名ans pwd,但是我从哪里得到另外两个:dbpath和rootProject?我得到它:
使用SourceSafeTypeLib;VSSDatabaseClass vssDatabase=新的VSSDatabaseClass();打开(“VSS数据库路径”、“用户名”、“密码”);VSSItem item=vssDatabase.get_VSSItem(“文件路径如vss所示”,false);item.Checkout(“注释”,item.LocalSpec,0);使用(StreamWriter sw=File.AppendText(lblSourceFile.Text)){sw.WriteLine(“Text”);}item.Checkin(“Comments”,item.LocalSpec,0);vssDatabase.Close()谢谢。您的“vss中显示的文件路径”是否与lblSourceFile.Text相同?