I just wondering what is the best way to join domain name and username
for instance :
string domainName = @"DTS\";
string username = "jake";
string domainUser = domainName + usernName;
Please advise
I just wondering what is the best way to join domain name and username
for instance :
string domainName = @"DTS\";
string username = "jake";
string domainUser = domainName + usernName;
Please advise
You can do it as Stay Foolish has recommended.
If you want to use the currently logged in user, instead of hard coding the user, you can use Environment.UserDomainName
and Environment.UserName
string domainUser = String.Format(
@"{0}\{1}",
Environment.UserDomainName,
Environment.UserName);
Use:
string.format(@"{0}\{1}", domainName, userName)
In that case you don't need to put the '\' in the domain name.
string domainName = @"DTS\";
Or
string domainName = "DTS\\";