How to get Computer Name from the LAN in c#.net





Download Project : GetNetworkIpAddress.zip
1.   first you have to a namespace
              using System.IO;
using System.Net;
using System.Net.NetworkInformation;

2.       now .
                         Process netUtility = new Process();

            netUtility.StartInfo.FileName = "net.exe";

            netUtility.StartInfo.CreateNoWindow = true;

            netUtility.StartInfo.Arguments = "view";

            netUtility.StartInfo.RedirectStandardOutput = true;

            netUtility.StartInfo.UseShellExecute = false;

            netUtility.StartInfo.RedirectStandardError = true;

            netUtility.Start();



StreamReader streamReader =StreamReader(netUtility.StandardOutput.BaseStream,                       netUtility.StandardOutput.CurrentEncoding);



3.       now make loop
                        string line = "";

              while ((line = streamReader.ReadLine()) != null)
              {
                if (line.StartsWith("\\"))
                {
                   
listBox1.Items.Add(line.Substring(2).Substring(0, line.Substring(2).IndexOf(" ")).ToUpper());
                }
              }

            streamReader.Close();
            netUtility.WaitForExit(1000);



See Also :
  Follow Me On Facebook

--
/\/ir@\/  <(.'.)>

Comments

Popular posts from this blog

How to make and use web service in Microsoft Dynamics Navision.

How to use Format function in Microsoft Dynamics Navision.

How to create simple report in Microsoft Dynamics Navision.