IVSSUser.Delete MethodÂ
Deletes a IVSSUser from the current SourceSafe database.
Namespace: Microsoft.VisualStudio.SourceSafe.Interop
Assembly: Microsoft.VisualStudio.SourceSafe.Interop (in microsoft.visualstudio.sourcesafe.interop.dll)
Syntax
'Declaration
Sub Delete
'Usage
Dim instance As IVSSUser
instance.Delete
void Delete ()
void Delete ()
void Delete ()
function Delete ()
Remarks
[IDL]
HRESULT Delete();
Only Admin can call the Delete method. If a user other than Admin attempts to call the Delete method, a run-time error is generated.
Example
The following example demonstrates how to use the Delete method to remove a IVSSUser from the SourceSafe database.
using System;
using Microsoft.VisualStudio.SourceSafe.Interop;
public class IVSSTest
{
private static void DisplayUsers(IVSSDatabase vssDatabase)
{
Console.Write("Database Users:");
foreach(IVSSUser vssUser in vssDatabase.Users)
Console.Write(" {0}", vssUser.Name);
Console.WriteLine();
}
private static string GetUsername()
{
Console.Write("Enter Username: ");
return Console.ReadLine();
}
private static string GetPassword()
{
Console.Write("Enter Password: ");
return Console.ReadLine();
}
public static void Main()
{
// Create a VSSDatabase object.
IVSSDatabase vssDatabase = new VSSDatabase();
// Only SourceSafe Admin can add a new user.
Console.WriteLine("Admin login");
vssDatabase.Open(@"C:\VSSTestDB\srcsafe.ini",
GetUsername(), GetPassword());
DisplayUsers(vssDatabase);
// Add new user to the database.
Console.WriteLine("Add New User");
IVSSUser vssUser =
vssDatabase.AddUser(GetUsername(), GetPassword(), false);
DisplayUsers(vssDatabase);
// Remove a user from the database
vssUser.Delete();
DisplayUsers(vssDatabase);
}
}
Output:
Admin login
Enter Username:
Enter Password:
Database Users: Admin Guest1 Guest2
Add New User
Enter Username: NewUser
Enter Password:
Database Users: Admin Guest1 Guest2 NewUser
Database Users: Admin Guest1 Guest2 (NewUser is removed)
See Also
Reference
IVSSUser Interface
IVSSUser Members
Microsoft.VisualStudio.SourceSafe.Interop Namespace