Just recieved this question in email and thought i would post the answer on blog too:

 

**************************

Question:

Hey Chuck!

Just a really quick Q for you if you can remember this on top of your head at all…apparently there’s a new ‘My…something’ class within .Net 2 that allows you to access the currently logged on user.  We’ve searched on the net and I’m afraid we’re not quite specific enough!  Do you know this class and which namespace it’s in at all?

 

Answer:

Hello,

This functionality is in the Microsoft.VisualBasic namespace and can be accessed like below:

 

MessageBox.Show(My.User.Name.ToString())

 

In C# you need to add a reference to the Namespace I referenced above and accessed via the following code:

 

//using Microsoft.VisualBasic;

Computer myComputer = new Computer();

MessageBox.Show(myComputer.Name.ToString());

 

 

-Chuck