Breaking News
Loading...
Sunday 6 July 2014

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@\/  <(.'.)>

0 comments:

Post a Comment

Thanks for comment

 
Toggle Footer