728x90
public string BringIP()
        {
            IPHostEntry host = Dns.GetHostEntry(Dns.GetHostName());
            string ip = string.Empty;
 
            for (int i = 0; i < host.AddressList.Length; i++)
                if (host.AddressList[i].AddressFamily == AddressFamily.InterNetwork)
                    ip = host.AddressList[i].ToString();
 
            return ip;
        }
      
 
        public Form1()
        {
            InitializeComponent();
            
            byte[] ip = BringIP().Split('.').Select(s => Byte.Parse(s)).ToArray();
            if (BitConverter.IsLittleEndian)
            {
                Array.Reverse(ip);
            }
            uint num = BitConverter.ToUInt32(ip, 0);
 
            txtServerIP.Text = num.ToString();
        }


'Study > C#' 카테고리의 다른 글

c# docx 에서 텍스트 얻기  (0) 2020.10.28
c#트랙바를 통한 볼륨 조절  (0) 2017.05.18
C# Thread  (0) 2017.04.24
C# MS-SQL 연동  (0) 2017.04.14
C# 네트워크 기본  (1) 2017.04.12

+ Recent posts