ip address - Run command prompt commands in c# -


is there way run command prompt commands within c# application? need name of computer way can access typing in cmd prompt.

nslookup myipadress

like if ip 134.123.12.12 type;

nslookup 134.123.12.12

and value returns after name: after. how in c# console application?

i've tried using

string name1 = environment.machinename; console.writeline(name1); string name2 = system.net.dns.gethostname(); console.writeline(name2); string name3 = system.net.dns.gethostentry("localhost").hostname; console.writeline(name3); string name4 =dnslookup("134.123.12.12"); string name5 = system.net.dns.gethostentry(134.123.12.12).hostname; console.writeline(name5); 

but none of these produce correct name, give me server/host name of computer. ideas?

i got code might work you.

here give internet name:

string name = system.net.dns.gethostentry("192.168.1.254").hostname; console.writeline(name); console.readline(); 

and here give ip address:

system.net.iphostentry host; string localip = "?"; host = system.net.dns.gethostentry(system.net.dns.gethostname()); foreach (system.net.ipaddress ip in host.addresslist) {     if (ip.addressfamily == system.net.sockets.addressfamily.internetwork)     {         localip = ip.tostring();         console.writeline(localip);     } } console.readline(); return; 

this might not best way works!

hope helps!!


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -