c#, winform app, how do I retrieve the users (internet) ip address?

c#, winform app, how do I retrieve the users (internet) ip address?
amillyardAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Éric MoreauSenior .Net ConsultantCommented:
In VB.Net, I have this code:
Dim strHostName As String
 
strHostName = System.Net.Dns.GetHostName()
Return System.Net.Dns.GetHostEntry(strHostName).AddressList(0).ToString

Open in new window

0
amillyardAuthor Commented:
well, I have got as far as this, but not working yet:  (c# version)

string strHostName = System.Net.Dns.GetHostName();
string strIPAddress = System.Net.Dns.GetHostEntry(strHostName).AddressList(0).ToString;
0
Éric MoreauSenior .Net ConsultantCommented:
you have 2 errors:
string strHostName = System.Net.Dns.GetHostName();
string strIPAddress = System.Net.Dns.GetHostEntry(strHostName).AddressList[0].ToString();

Open in new window

0
Become a CompTIA Certified Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

amillyardAuthor Commented:
I see.  This appears to work, but I am not getting the normal ip address format xxx.xxx.xxx.xxx

my ip address came back as:   fe80::180b:31f2:

how do I convert this?
0
Éric MoreauSenior .Net ConsultantCommented:
I don't know. I am getting a normal IP address.
0
amillyardAuthor Commented:
mmm... I see -- is it a Vista issue? -- newer ip address protocol standard or something?
0
Éric MoreauSenior .Net ConsultantCommented:
maybe, I have XP at work (and no Vista under hands to try it)
0
Éric MoreauSenior .Net ConsultantCommented:
from http://bytes.com/forum/thread493790.html, can you try

Public Function Get_LocalIPAddress() As String

Dim h As System.Net.IPHostEntry =
System.Net.Dns.GetHostEntry(System.Net.Dns.GetHost Name)

'return any string found

Get_LocalIPAddress = CType(h.AddressList.GetValue(0), System.Net.IPAddress).ToString

End Function
0
Éric MoreauSenior .Net ConsultantCommented:
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
amillyardAuthor Commented:
many thanks :-)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.