문제

I have a project with Visual Source Safe (VSS) and I need to append lines to a ".sql" file. I am trying to use the obvious code:

using (StreamWriter sw = File.AppendText(lblSourceFile.Text))
{
    sw.WriteLine("text here");
}

But I am getting "File Access" error because the file is not checked out in the VSS. Is there a way to programmaticlly check-out the file for edit and check it back in when finish ? All links I found are using VSSDatabaseClass, and I don't how to add reference for SourceSafetypelib dll and use VSSDatabaseClass...

도움이 되었습니까?

해결책 2

Thanks to Rachel for the ssapi.dll file. Here is the code that worked for my:

 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();

다른 팁

You can add ssapi.dll, which can be found in the installation folder of VSS, as reference and then you can use SourceSafetypelib. Here you can see a sample.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top