# Mac Address 취득 코드
private static string GetMacAddress() { return NetworkInterface.GetAllNetworkInterfaces()[0].GetPhysicalAddress().ToString(); } private static string MacFormat(string str) { string mac = ""; char[] chrArr = str.ToCharArray(); for (int i = 0; i < chrArr.Length; i++) { if (i % 2 == 0) { mac += chrArr[i].ToString(); } else { mac += chrArr[i].ToString(); if (i != chrArr.Length - 1) mac += ":"; } } return mac; }
# IP Address 취득 코드
private static string GetIPAddress() { string ip=""; IPAddress[] host = Dns.GetHostAddresses(Dns.GetHostName()); foreach(var item in host) { if(item.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) { ip = item.ToString(); } } return ip; }
[출처: https://m.blog.naver.com/PostList.nhn?blogId=leegh1587]