Hi everyone,
I am trying to connect different computers to an ad-hoc network, but every time that two computers are assigned to the same IP windows shows a conflict error message.
Is there any way to detect this error programmatically? so I can assign the latest computer added to the network to a different IP.
Thanks in advance for any help

Javeed M ShaikhRank #839 · 2.7K reputationPosted Oct 26, 2011, 8:10 AM EDT
can you get the IP Addresses of all the local computer in the network and than find out if there is a duplicate and work from there.
IPAddress[] arrayOfIPAddresses = Dns.GetHostByName(Dns.GetHostName()).AddressList;
for (int i=0; i<arrayOfIPAddresses.Length; i++)
Console.WriteLine ("IPAddress[{0}]={1}",i,arrayOfIPAddresses[i]); }
Sam HobbsRank #107 · 20.5K reputationPosted Oct 26, 2011, 9:01 AM EDT
("Select Name, Caption, DisplayType, Description from Win32_NetworkConnection");
foreach (ManagementObject nc in NetworkConnections.Get())
{
Console.WriteLine("{0} | {1} | {2} | {3}", nc["Name"], nc["Caption"], nc["DisplayType"], nc["Description"]);
}
Sam HobbsRank #107 · 20.5K reputationPosted Oct 26, 2011, 9:05 AM EDT
Toni3 reputationPosted Oct 27, 2011, 12:37 AM EDT
Thank you for your reply, unfortunately your solution only bring the IP addresses for the local computer where I execute the code. I need to find the computers connected to an ad-hoc network, so I can assign a different IP to the new computer added to this network.
Thank you for your help.
Regards,
Toni
Sam HobbsRank #107 · 20.5K reputationPosted Oct 27, 2011, 11:54 AM EDT
Either the problem you are trying to solve is a common problem and there is a common solution, or there is something unique to your situation yet that part is not clear. If you can explain why your situation is different then it is more likely that someone can help you.