read keys,values from Command lines

want help with my program to read ping and check it

Page 1 of 1

3 Replies - 1047 Views - Last Post: 15 January 2009 - 02:52 AM Rate Topic: -----

#1 elragal_30  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 12-January 09

read keys,values from Command lines

Posted 13 January 2009 - 12:52 AM

hello all
i am quite Beginner at C sharp language i teach y self
and as my INTERNET is bad i try make application that make action when ping return hight values
now i make this :

//create new process that get"ping www.yahoo.com -t"  from pingg.bat file
 System.Diagnostics.ProcessStartInfo ping_Procs = new System.Diagnostics.ProcessStartInfo(Application.StartupPath+@"\pingg.bat");

								ping_Procs.RedirectStandardOutput = true;
				ping_Procs.UseShellExecute = false;
								// Now we create a process, assign its ProcessStartInfo and start it
				System.Diagnostics.Process write_Procs = new System.Diagnostics.Process();
				write_Procs.StartInfo = ping_Procs;
				write_Procs.Start();	 
//make string get ping replay and pass it to stream writer			
				string out_put = write_Procs.StandardOutput.ReadToEnd();
				
				label1.Text = out_put;
			
				System.IO.StreamWriter strm_wrt = new System.IO.StreamWriter(Application.StartupPath + @"\ss.txt", true);
				strm_wrt.Write(res);



first the stream not write ping until i close Ping's CMD Window
second what is the best is write replays to file or to save it at variable ??
3- now i want to make check every line on ping to know time= ??
like this :

Quote

Reply from 87.248.113.14: bytes=32 time=128ms TTL=50
Reply from 87.248.113.14: bytes=32 time=130ms TTL=50
Reply from 87.248.113.14: bytes=32 time=130ms TTL=50
Reply from 87.248.113.14: bytes=32 time=127ms TTL=50
Reply from 87.248.113.14: bytes=32 time=128ms TTL=50
Reply from 87.248.113.14: bytes=32 time=138ms TTL=50
Reply from 87.248.113.14: bytes=32 time=127ms TTL=50
Reply from 87.248.113.14: bytes=32 time=126ms TTL=50

i was think about INI file but some tell me not use it and use XML
what is the best ??
about "INI 's file" i was think that was some method that can read keys separated by "Space or ","
so i bypass (1,2,3,4) and check NO#5 remove "time" then see if it is >800ms then do the required action
if u have method to do that with out using a lot memory ok tell me
sorry if tall,but the idea is so useful for me
help appreciate
thanks

Is This A Good Question/Topic? 0
  • +

Replies To: read keys,values from Command lines

#2 n8wxs  Icon User is offline

  • --... ...-- -.. . -. ---.. .-- -..- ...
  • member icon

Reputation: 972
  • View blog
  • Posts: 3,878
  • Joined: 07-January 08

Re: read keys,values from Command lines

Posted 13 January 2009 - 04:05 AM

Please have a look at Ping Class, a member of the System.Net.NetworkInformation Namespace
See also the classes of the System.Net Namespace

The Ping Class documentation has an example console application you can use.

This post has been edited by n8wxs: 13 January 2009 - 04:07 AM

Was This Post Helpful? 1
  • +
  • -

#3 elragal_30  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 12-January 09

Re: read keys,values from Command lines

Posted 14 January 2009 - 02:03 AM

thanks it is very good link for a lot of tutorials
maybe my foolish that i think that was nothing like these at .NetFrameWork and System
i read them and back when finishing
thanks again
Was This Post Helpful? 0
  • +
  • -

#4 n8wxs  Icon User is offline

  • --... ...-- -.. . -. ---.. .-- -..- ...
  • member icon

Reputation: 972
  • View blog
  • Posts: 3,878
  • Joined: 07-January 08

Re: read keys,values from Command lines

Posted 15 January 2009 - 02:52 AM

View Postelragal_30, on 14 Jan, 2009 - 01:03 AM, said:

thanks it is very good link for a lot of tutorials
maybe my foolish that i think that was nothing like these at .NetFrameWork and System
i read them and back when finishing
thanks again

I was looking for something else and came across this tutorial here on Dream.In.Code: Using the Ping Class in C#

Hopefully, this will help you as well. :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1