473,320 Members | 1,957 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

use .NET to get IP of my machine

This should be easy to do, however I can't seem to figure it out. How can I
find the IP of my machine using .NET
thanks,
Ron
Nov 23 '05 #1
2 945
using System;
using System.Net;

class Test {

public static void Main() {
IPAddress[] a = Dns.GetHostByName(Dns.GetHostName()).AddressList;
for (int i=0; i<a.Length; i++)
Console.WriteLine ("IpAddr[{0}]={1}",i,a[i]); }

}

hope this may help
--
Happy Coding
Muhanad YOUNIS
MCSD.NET / MCT
http://myounis.blogspirit.com

Be the first to know visit http://www.jordev.net
"RonB" wrote:
This should be easy to do, however I can't seem to figure it out. How can I
find the IP of my machine using .NET
thanks,
Ron

Nov 23 '05 #2
VB translation...

Imports System
Imports System.Net

Friend Class Test
Public Shared Sub Main()
Dim a() As IPAddress =
Dns.GetHostByName(Dns.GetHostName()).AddressList
For i As Integer = 0 To a.Length
Console.WriteLine("IP Address [" & i.ToString & "] = " &
a(i).ToString)
Next
End Sub
End Class

Just in case the OP doesn't speak C [and yes.. I'm bored :P]
_______________________________________________
The Grim Reaper

"mos2128" <mo*****@discussions.microsoft.com> wrote in message
news:E6**********************************@microsof t.com...
using System;
using System.Net;

class Test {

public static void Main() {
IPAddress[] a = Dns.GetHostByName(Dns.GetHostName()).AddressList;
for (int i=0; i<a.Length; i++)
Console.WriteLine ("IpAddr[{0}]={1}",i,a[i]); }

}

hope this may help
--
Happy Coding
Muhanad YOUNIS
MCSD.NET / MCT
http://myounis.blogspirit.com

Be the first to know visit http://www.jordev.net
"RonB" wrote:
This should be easy to do, however I can't seem to figure it out. How can
I
find the IP of my machine using .NET
thanks,
Ron

Nov 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Marina Anufreichik | last post by:
Hi, After deploymnet web application on web server I can access page on local machine and login fine but when I'm trying to access web site from remote machine I can see login page, but when I'm...
10
by: Marina Anufreichik | last post by:
Hi, After deploymnet web application on web server I can access page on local machine and login fine but when I'm trying to access web site from remote machine I can see login page, but when I'm...
27
by: Javier Martinez | last post by:
Hi I have asp application in a machine with a virtual directory referring a shared directory in another machine When I try to load any aspx page of my portal I get the following error: ...
9
by: Marina Anufreichik | last post by:
Hi, After deploymnet web application on web server I can access page on local machine and login fine but when I'm trying to access web site from remote machine I can see login page, but when I'm...
11
by: TARUN | last post by:
Hello All I need to ask about the configuration file in .NET, There are Two config File 1. Web Config 2. Machine config I understand the the usage of Web config , but not able to understand...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.