Proprietà IVSSItem.Name

Ottiene o imposta il nome di un file o di un progetto.

Spazio dei nomi: Microsoft.VisualStudio.SourceSafe.Interop
Assembly: Microsoft.VisualStudio.SourceSafe.Interop (in microsoft.visualstudio.sourcesafe.interop.dll)

Sintassi

'Dichiarazione
Property Name As String
'Utilizzo
Dim instance As IVSSItem
Dim value As String

value = instance.Name

instance.Name = value
string Name { get; set; }
property String^ Name {
    String^ get ();
    void set ([InAttribute] String^ pName);
}
/** @property */
String get_Name ()

/** @property */
void set_Name (/** @attribute InAttribute() */ String pName)
function get Name () : String

function set Name (pName : String)

Valore proprietà

Una stringa che rappresenta il nome di un file o di un progetto.

Note

[IDL]

HRESULT Name ([out,retval]BSTR *pName);

HRESULT Name ([in]BSTR Name);

Questa proprietà non include un percorso in Visual SourceSafe. Ad esempio, la proprietà Name di $/MyProject/MyFile.txt è MyFile.txt.

Se si tenta di rinominare il progetto di primo livello o di rinominare un file o un progetto con il nome di un file o di un progetto esistente, verrà generato un errore di run-time.

Il valore della proprietà Name del progetto di primo livello è una stringa vuota.

Esempio

Nell'esempio riportato di seguito viene illustrato come utilizzare la proprietà Name per ottenere i nomi di un file e di un progetto e per impostare un nuovo nome per un file. Per eseguire l'esempio:

  • Creare un progetto $/TestFolder.

    Il progetto $/TestFolder contiene: test.txt

[C#]

using System;
using Microsoft.VisualStudio.SourceSafe.Interop;

public class IVSSTest
{
    public static void Main()
    {
        // Create a VSSDatabase object.
        VSSDatabase 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("$/TestFolder", false);
        IVSSItem vssFile = 
                 vssDatabase.get_VSSItem("$/TestFolder/test.txt", false);
        
        Console.WriteLine("'{0}' project name is '{1}'", 
                          vssFolder.Spec, vssFolder.Name);
        Console.WriteLine("'{0}' file name is '{1}'", 
                          vssFile.Spec, vssFile.Name);
        
        // Rename a file.
        vssFile.Name = "testNew.txt";
        Console.WriteLine("'{0}' new file name is '{1}'", 
                          vssFile.Spec, vssFile.Name);
        // Restore original filename.
        vssFile.Name = "test.txt";
    }
}

Output:

'$/TestFolder' project name is 'TestFolder'

'$/TestFolder/test.txt' file name is 'test.txt'

'$/TestFolder/testNew.txt' new filename is 'testNew.txt'

[Visual Basic]

Imports System
Imports Microsoft.VisualStudio.SourceSafe.Interop

Module IVSSTest

    Public Sub Main()

        ' Create a VSSDatabase object.
        Dim vssDatabase As 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.
        Dim vssFolder As IVSSItem = _
                         vssDatabase.VSSItem("$/TestFolder", False)
        Dim vssFile As IVSSItem = _
                       vssDatabase.VSSItem("$/TestFolder//test.txt", False)

        Console.WriteLine("'{0}' project name is '{1}'", _
                          vssFolder.Spec, vssFolder.Name)
        Console.WriteLine("'{0}' file name is '{1}'", _
                          vssFile.Spec, vssFile.Name)

        ' Rename a file.
        vssFile.Name = "testNew.txt"
        Console.WriteLine("'{0}' new file name is '{1}'", _
                          vssFile.Spec, vssFile.Name)
        ' Restore original file name.
        vssFile.Name = "test.txt"

    End Sub

End Module

Output:

'$/TestFolder' project name is 'TestFolder'

'$/TestFolder/test.txt' file name is 'test.txt'

'$/TestFolder/testNew.txt' new filename is 'testNew.txt'

Vedere anche

Riferimenti

Interfaccia IVSSItem
Membri IVSSItem
Spazio dei nomi Microsoft.VisualStudio.SourceSafe.Interop