Click here to Skip to main content
15,892,809 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,
Does anybody know how to get the IPAddress of the Laptop
I have a little code that works very well in my computer stationary, but it doesnt works in the Laptop

here is the code...

IPAddress [] IPAddr = DNS.GetHostByName(Dns.GetHostName()).AddressList;
string ip = IPAddr[1].ToString();

thank you all...
Posted

It is in there already,I think it is different from computer to computer what place in the array your standard ip is (192.168.1.1).

Loop through it and you will find.

IPAddress[] IPAddr = Dns.GetHostEntry(Dns.GetHostName()).AddressList;
            for (int i = 0; i < IPAddr.Length; i++)
                Console.WriteLine(IPAddr[i].ToString());


On my laptop the ipv4 adress was on IPAddr[2]
 
Share this answer
 
If you are using the default setup (using DHCP), your laptop doesn't have an IP address until it's actually connected to a network. If you type "ipconfig /all" at a command prompt you can see all your network connections. That way, you can see if there is anything for DNS to give you.
 
Share this answer
 
Well thats what I got...

MSIL
fe80::b450:c989:5f9b:381c%12
fe80::108e:12d2:b281:ca66%17
192.168.0.178
2001:0:4137:9e74:108e:12d2:b281:ca66


what is it?
and my ip not exist there...
 
Share this answer
 
Comments
Per Söderlund 6-Sep-10 1:16am    
That is your ip adresses.
Are you looking for something else?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900