Website and Host Address Ip Address Query Tool with C #

in #utopian-io7 years ago (edited)

Hello there!
Using the System.Net library with you today.
Türkçe:

Kendi bilgisayarımızın ip adresini ve metin kutusuna yazdığımız web sitesi adresinin ip adresini öğrendiğimizde ilk olarak yeni bir proje oluşturduk ve formumuza 2 metin kutusu, 2 etiket ve 1 düğme ekledik;
Screenshot_1.jpg

Button Click olayımıza kod yazmaya başlamadan önce System.Net kitaplığımızı kodumuza eklemeliyiz.

using System.Net;

Sınıf ekledik
Screenshot_2.jpg

Ve Düğme Tıklama Etkinlik Kodları aşağıdaki gibidir;

textBox1.Text = ("Bilgisayar:" + Dns.GetHostName());
            foreach (IPAddress adres in Dns.GetHostAddresses(Dns.GetHostName()))
            {
                textBox2.Text = adres.ToString();

Kendi bilgisayarımızın adresini ve adını aldık. Yazdığımız web sitesinin ip adresini gösterecek kodları formumuzun devamı olarak yazalım.
Bunun için 2 etiketli 2 metin kutusu 1 düğmesi ekledik.
Screenshot_3.jpg

Ardından liste görünümündeki simgeyi tıklar ve düzenleme sütununa yazar ve ekle düğmesini iki kez tıklarız. Ve site adresini 1. sütun metne, 2. site metnini ise site lp adresine yazıyoruz.Screenshot_4.jpg
Screenshot_5.jpg

Button Click etkinliğine başlamadan önce size hatırlatmak isterim. Kullanıcının metin kutusuna yazdığı değer yanlışsa, steemit.com yerine stemit.com yazıp, daha sonra programı "try catch" bloğuna koyduğumuzu ve böylece "try" düğmesini tıkladığınızı ve programın otomatik olarak iki kez sekmeye bastığımızda bloğu tamamlayın.
If button 2 is click event,

private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                IPHostEntry siteadi = Dns.GetHostEntry(textBox4.Text);
                IPAddress[] ip = siteadi.AddressList;
                textBox3.Text = ip[0].ToString();
            }
            catch (Exception)
            {
                MessageBox.Show("Böyle Bir site Bulunamadı");
            }
        }

Codes Index;
Screenshot_6.jpg
Screenshot_8.jpg
Screenshot_7.jpg
Sonuç:
Screenshot_9.jpg
If the website is misspelled, the result is;
Screenshot_10.jpg

Github Profile And Link:
https://github.com/javatorman/Ipadresogren
Screenshot_11.jpg

I hope it has been a useful article thank you all.



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Your contribution cannot be approved because it does not follow the Utopian Rules.

Submissions to the development category should be about merged contributions to existing open source projects, or valuable new open source projects.

This article is more akin to a stock-standard tutorial, and thus I am unable to accept it.

You can contact us on Discord.
[utopian-moderator]

category updated.

Coin Marketplace

STEEM 0.18
TRX 0.13
JST 0.028
BTC 58484.86
ETH 3100.06
USDT 1.00
SBD 2.40