Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Branches a file that has been shared between one or more projects.
Namespace: Microsoft.VisualStudio.SourceSafe.Interop
Assembly: Microsoft.VisualStudio.SourceSafe.Interop (in microsoft.visualstudio.sourcesafe.interop.dll)
Syntax
'Declaration
Function Branch ( _
    <InAttribute> <OptionalAttribute> Optional Comment As String = "", _
    <InAttribute> <OptionalAttribute> Optional iFlags As Integer = 0 _
) As VSSItem
'Usage
Dim instance As IVSSItem
Dim Comment As String
Dim iFlags As Integer
Dim returnValue As VSSItem
returnValue = instance.Branch(Comment, iFlags)
VSSItem Branch (
    [OptionalAttribute] [InAttribute] string Comment,
    [OptionalAttribute] [InAttribute] int iFlags
)
VSSItem^ Branch (
    [InAttribute] [OptionalAttribute] String^ Comment, 
    [InAttribute] [OptionalAttribute] int iFlags
)
VSSItem Branch (
    /** @attribute InAttribute() */ /** @attribute OptionalAttribute() */ String Comment, 
    /** @attribute InAttribute() */ /** @attribute OptionalAttribute() */ int iFlags
)
function Branch (
    Comment : String, 
    iFlags : int
) : VSSItem
Parameters
- Comment
Optional. The default value is 0. For more information, see VSSFlags. 
- iFlags
Optional. A string containing a comment. The default is an empty string. 
Return Value
A reference of the IVSSItem type to an object that represents a newly branched file.
Remarks
[IDL]
HRESULT Branch([in, defaultvalue(0)] BSTR Comment, [in, defaultvalue(0)] long iFlags, [out, retval] IVSSItem **ppIItem);
The Branch method applies to file objects only. If you attempt to branch a file that is not shared or branch a project object, a run-time error is generated.
Example
The following example demonstrates how to use the Branch method to branch a file that has been shared by two projects. To run this example:
Create two folders, $/A and $/B.
$/A folder must contain a file named a.txt.
[C#]
using System;
using Microsoft.VisualStudio.SourceSafe.Interop;
public class IVSSTest
{
    public static void Main()
    {
        // Create a VSSDatabase object.
        IVSSDatabase vssDatabase = new VSSDatabase();
        // Open a VSS database using network name 
        // for automatic user login.
        vssDatabase.Open(@"C:\VSSTestDB\srcsafe.ini", 
                         Environment.UserName, ""); 
        // Get IVSSItem references to the project and the file objects.
        IVSSItem vssFolder = vssDatabase.get_VSSItem("$/B", false);
        VSSItem vssFile1 = vssDatabase.get_VSSItem("$/A/a.txt", false);
        DisplayLinks(vssFile1);
        // Share a file between two folders.
        vssFolder.Share(vssFile1, "Comment for share", 0);
        DisplayLinks(vssFile1);
        IVSSItem vssFile2 = vssDatabase.get_VSSItem("$/B/a.txt", false);
        // Break the shared link between folders $/A and $/B on file a.txt.
        vssFile2.Branch("Branch comment", 0);
        DisplayLinks(vssFile1);
        // Destroy file a.txt in folder $/B:
        vssFile2.Destroy();
    }
    private static void DisplayLinks(IVSSItem vssFile)
    { 
        Console.Write("\n{0} contains links:", vssFile.Spec);
        foreach(IVSSItem vssItem in vssFile.Links)
            Console.Write("  {0}", vssItem.Spec);
    }
}
Output:
$/A/a.txt contains links: $/A/a.txt
$/A/a.txt contains links: $/B/a.txt $/A/a.txt
$/A/a.txt contains links: $/A/a.txt
See Also
Reference
IVSSItem Interface
IVSSItem Members
Microsoft.VisualStudio.SourceSafe.Interop Namespace