IVSSItem.Name Property
Gets or sets a name of a file or a project.
Namespace: Microsoft.VisualStudio.SourceSafe.Interop
Assembly: Microsoft.VisualStudio.SourceSafe.Interop (in microsoft.visualstudio.sourcesafe.interop.dll)
Syntax
'Declaration
Property Name As String
'Usage
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)
Property Value
A string representing a name of a file or a project.
Remarks
[IDL]
HRESULT Name ([out,retval]BSTR *pName);
HRESULT Name ([in]BSTR Name);
This property does not include a SourceSafe path. For example, the Name property of $/MyProject/MyFile.txt is MyFile.txt.
If you attempt to rename the root project or rename a file or a project to the name of an existing file or project, a run-time error is generated.
The value of the Name property of the root project is an empty string.
Example
The following example demonstrates how to use the Name property to get the names of a file and a project and set a new name to a file. To run this example:
Create a $/TestFolder project.
The $/TestFolder contains: 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'
See Also
Reference
IVSSItem Interface
IVSSItem Members
Microsoft.VisualStudio.SourceSafe.Interop Namespace