Click here to Skip to main content
15,898,134 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello.

I want to know is there any way we can get an ip address range of an network or DNS suffix name.

Example, when i type ipconfig in commandprompt, i will get information as below

XML
<pre lang="css">
Ethernet adapter Local Area Connection:

   Connection-specific DNS Suffix  . : COMPANY-NAME-MY
   Link-local IPv6 Address . . . . . : fe80::3134:1e1b:f018:7280%22
   IPv4 Address. . . . . . . . . . . : 192.168.2.140
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 192.168.2.1

</pre>

i want to get Connection-specific DNS Suffix value from my c-sharp page..is it possible?

thanks.
Posted

1 solution

C#
try
          {

              System.Diagnostics.ProcessStartInfo runcmd =
              new System.Diagnostics.ProcessStartInfo("cmd", "/c " + "ipconfig");


              runcmd.RedirectStandardOutput = true;
              runcmd.UseShellExecute = false;
              runcmd.CreateNoWindow = true;
              System.Diagnostics.Process proc = new System.Diagnostics.Process();
              proc.StartInfo = runcmd;
              proc.Start();
              string result = proc.StandardOutput.ReadToEnd();
              textBox1.Text = result;

          }
          catch (Exception objException)
          {
              // write here you carch.
          }


hope this helps...
 
Share this answer
 
Comments
Mukund Thakker 22-Feb-12 8:05am    
Gives following error
Security Exception
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

Exception Details: System.Security.SecurityException: Request failed.
ajit_machhe 22-Feb-12 16:17pm    
Hi Mukund,

i am using windows 7 ultimate edition and vs2010 and using as an administrator so i never had this error.
i am sorry for the error but still not sure why the error was occured ?

i will see if something i can do.
meanwhile... please try to login as administrator and run the code again.
pwtc222 25-Feb-12 13:40pm    
is this code is to read information from client side?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900