Windows Forms: Ping an IP address in C#
By FoxLearn 12/27/2019 3:30:19 AM 9.02K
This post shows you How to Ping an IP address using C# .NET Windows Forms Application.
Dragging Label, TextBox and Button controls from the Visual Studio Toolbox to your form designer.
Adding a click event handler to the Ping button allows you to ping an ip address.
private void btnPing_Click(object sender, EventArgs e) { Ping ping = new Ping(); PingReply reply = ping.Send(txtIP.Text, 1000); MessageBox.Show(reply.Status.ToString(), "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); }
And don't forget to include the namespace below to your form.
using System.Net.NetworkInformation;
The PING class determines whether a remote computer can be accessed over the network. It provides the same functionality as the PING.EXE command line tool.
- How to Add Active Navigation Class Based on URL
- How to Display popup message in Javascript
- How to Show message instead of alert
- How to fix 'Uncaught TypeError: Cannot read property 'fn' of undefined'
- How to Format numbers with commas in Javascript
- How to format number with commas and decimal in Javascript
- How to Pass string parameter in an onclick function
- How to get @Url.Action url in a separate script file?
Categories
Popular Posts
Visual Studio: Auto increment version
04/01/2024
What is ARM architecture?
04/01/2024