Replace Program.cs with the following code
snippet.
namespace
UserProfileTesting
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using
Microsoft.Office.Server.UserProfiles;
using Microsoft.SharePoint;
class
Program
{
public
static void Main(string[]
args)
{
using (SPSite
site = new
SPSite("https://servername.com/hrp/hrp/"))
{
//// SPServiceContext class is
used to represent a context object that encapsulates all the information
that is required to make a call to a user profile service application.
SPServiceContext
context = SPServiceContext.GetContext(site);
////ProfileSubtypeManager class is
used to create, delete, retrieve, and manage profile subtypes for a profile
type.
ProfileSubtypeManager
psm = ProfileSubtypeManager.Get(context);
//// Get the user
profile subtype
ProfileSubtype
subtype=psm.GetProfileSubtype("Finance");
//// Check whether the subtype
exists
if (subtype ==
null)
{
//// create a new user profile
subtype
//// Finance is the
Name of the subtype
//// Finance Subtype is
the Display name of the subtype
psm.CreateSubtype("Finance",
"Finance Subtype",
ProfileType.User);
}
else
{
Console.WriteLine(subtype.DisplayName
+ " already exists.");
Console.ReadLine();
}
}
}
}
}