Question

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...

Was it helpful?

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

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top