Partager via


Network Information Technology Sample

This sample shows how to create a Windows Forms application to monitor and display network information such as IP addresses, network interfaces, and statistics about network traffic to and from the local computer. These capabilities are provided by the types in the System.Net.NetworkInformation namespace.

For information about using the samples, see the following topics:

To build the sample using the command prompt

  1. Open a Command Prompt window and navigate to one of the language-specific subdirectories under the NetworkInformation directory. For information about required settings and the SDK Command Prompt, see How to: Set Sample Settings.

  2. Type msbuild NetworkInformation.sln at the command line.

To build the sample using Visual Studio

  1. Open Windows Explorer and navigate to one of the language-specific subdirectories under the NetworkInformation directory.

  2. Double-click the icon for NetworkInformation.sln to open the file in Visual Studio.

  3. On the Build menu, click Build Solution.

The application is built in the default \bin or \bin\Debug directory.

To run the sample

  1. Navigate to the directory that contains the new executable, using the command prompt or Windows Explorer.

  2. Type NetworkInformation.exe at the command line, or double-click the icon for NetworkInformation.exe to launch it from Windows Explorer.

Remarks

The sample application handles the NetworkAddressChanged event with its NetworkChange_NetworkAddressChanged method. This method calls the UpdateNetworkInformation method, which repopulates the ComboBox control that contains the value of the Description property of each available NetworkInterface.

Review comments in the source code and build.proj files for more information about monitoring network statistics.

See Also

Reference

IPInterfaceProperties
NetworkChange
NetworkInterface
OperationalStatus
System.Net.NetworkInformation