How to know current user name?

L

Lloyd Dupont

In my application I have a file with some information initialized to the
author's name.
I would like to pick it up automatically!
How do I do that?

--
Regards,
Lloyd Dupont

NovaMind development team
NovaMind Software
Mind Mapping Software
<www.nova-mind.com>
 
L

Lloyd Dupont

Mhh.... almost there...
I found that:
System.Security.Principal.WindowsIdentity.GetCurrent().Name

But the problem is, it returns that:
PC1\Lloyd Dupont

Is there a solution without the "Computer\" prefix?
 
M

Mattias Sjögren

In my application I have a file with some information initialized to the
author's name.
I would like to pick it up automatically!
How do I do that?

Systen.Environment.UserName


Mattias
 
M

Marc Scheuner [MVP ADSI]

Mhh.... almost there...
I found that:
System.Security.Principal.WindowsIdentity.GetCurrent().Name

But the problem is, it returns that:
PC1\Lloyd Dupont

Is there a solution without the "Computer\" prefix?

How about Environment.UserName ?

Marc
================================================================
Marc Scheuner May The Source Be With You!
Berne, Switzerland m.scheuner -at- inova.ch
 
P

Paul Clement

¤ Mhh.... almost there...
¤ I found that:
¤ System.Security.Principal.WindowsIdentity.GetCurrent().Name
¤
¤ But the problem is, it returns that:
¤ PC1\Lloyd Dupont
¤
¤ Is there a solution without the "Computer\" prefix?

If you want both it's easy enough to split:

MsgBox(System.Security.Principal.WindowsIdentity.GetCurrent.Name.Split("\"c)(1))
MsgBox(System.Security.Principal.WindowsIdentity.GetCurrent.Name.Split("\"c)(0))


Paul
~~~~
Microsoft MVP (Visual Basic)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top