Why doesn´t work the Code?
-
Hallo! What is the problem? I have the Server and Client form here http://board.gulli.com/thread/141481...t-fhig-machen/[^] So it works the fully code, i can open Word,Ecxel and shutdown in x sec.
f (get == "rWord") System.Diagnostics.Process.Start("winword"); if (get == "rExcel") System.Diagnostics.Process.Start("excel"); string[] get_Split = get.Split('~'); int time = Convert.ToInt32(get_Split[1]); if (get.Contains("rshutdown")) { System.Diagnostics.Process.Start("shutdown", "-s -t " + time.ToString()); } }
And so it do nothing!string[] get_Split = get.Split('~'); int time = Convert.ToInt32(get_Split[1]); if (get.Contains("rshutdown")) { System.Diagnostics.Process.Start("shutdown", "-s -t " + time.ToString()); } } if (get == "rWord") System.Diagnostics.Process.Start("winword"); if (get == "rExcel") System.Diagnostics.Process.Start("excel");
-
Hallo! What is the problem? I have the Server and Client form here http://board.gulli.com/thread/141481...t-fhig-machen/[^] So it works the fully code, i can open Word,Ecxel and shutdown in x sec.
f (get == "rWord") System.Diagnostics.Process.Start("winword"); if (get == "rExcel") System.Diagnostics.Process.Start("excel"); string[] get_Split = get.Split('~'); int time = Convert.ToInt32(get_Split[1]); if (get.Contains("rshutdown")) { System.Diagnostics.Process.Start("shutdown", "-s -t " + time.ToString()); } }
And so it do nothing!string[] get_Split = get.Split('~'); int time = Convert.ToInt32(get_Split[1]); if (get.Contains("rshutdown")) { System.Diagnostics.Process.Start("shutdown", "-s -t " + time.ToString()); } } if (get == "rWord") System.Diagnostics.Process.Start("winword"); if (get == "rExcel") System.Diagnostics.Process.Start("excel");
no one can understand your problem....:confused:
PC17 wrote:
What is the problem?
are you asking us to run the code and check the error and tell it to you.... :doh: please be a bit clear so that our experts can slove your problem and giude you in a correct way........ :)
Padmanabhan My Articles: Articles[^] My latest Article: Word Automation[^]
-
no one can understand your problem....:confused:
PC17 wrote:
What is the problem?
are you asking us to run the code and check the error and tell it to you.... :doh: please be a bit clear so that our experts can slove your problem and giude you in a correct way........ :)
Padmanabhan My Articles: Articles[^] My latest Article: Word Automation[^]
OK Sorry The first code i have posted works! And the Second is the same but the Array is in the end!This code doesn´t work!
-
Hallo! What is the problem? I have the Server and Client form here http://board.gulli.com/thread/141481...t-fhig-machen/[^] So it works the fully code, i can open Word,Ecxel and shutdown in x sec.
f (get == "rWord") System.Diagnostics.Process.Start("winword"); if (get == "rExcel") System.Diagnostics.Process.Start("excel"); string[] get_Split = get.Split('~'); int time = Convert.ToInt32(get_Split[1]); if (get.Contains("rshutdown")) { System.Diagnostics.Process.Start("shutdown", "-s -t " + time.ToString()); } }
And so it do nothing!string[] get_Split = get.Split('~'); int time = Convert.ToInt32(get_Split[1]); if (get.Contains("rshutdown")) { System.Diagnostics.Process.Start("shutdown", "-s -t " + time.ToString()); } } if (get == "rWord") System.Diagnostics.Process.Start("winword"); if (get == "rExcel") System.Diagnostics.Process.Start("excel");
-
Hallo! What is the problem? I have the Server and Client form here http://board.gulli.com/thread/141481...t-fhig-machen/[^] So it works the fully code, i can open Word,Ecxel and shutdown in x sec.
f (get == "rWord") System.Diagnostics.Process.Start("winword"); if (get == "rExcel") System.Diagnostics.Process.Start("excel"); string[] get_Split = get.Split('~'); int time = Convert.ToInt32(get_Split[1]); if (get.Contains("rshutdown")) { System.Diagnostics.Process.Start("shutdown", "-s -t " + time.ToString()); } }
And so it do nothing!string[] get_Split = get.Split('~'); int time = Convert.ToInt32(get_Split[1]); if (get.Contains("rshutdown")) { System.Diagnostics.Process.Start("shutdown", "-s -t " + time.ToString()); } } if (get == "rWord") System.Diagnostics.Process.Start("winword"); if (get == "rExcel") System.Diagnostics.Process.Start("excel");
Do you have an example value for "get" ? Also
System.Diagnostics.Process.Start("shutdown", "-s -t " + time.ToString());
will shut the machine down if called, not Word or Excel. -
OK Sorry The first code i have posted works! And the Second is the same but the Array is in the end!This code doesn´t work!
are you getting any error... because in your sample the first method and the second method both are same... the only difference is the ifstatement goes last and the arrar comes first...
Padmanabhan My Articles: Articles[^] My latest Article: Word Automation[^]
-
Do you have an example value for "get" ? Also
System.Diagnostics.Process.Start("shutdown", "-s -t " + time.ToString());
will shut the machine down if called, not Word or Excel.It´s difficut to explain it! I have a Server and a Client. the Client have many Buttons for examble open Word , shutdown,... When i use this code in the Server i can click on open Word or shutdown both works!
if (get == "rWord") System.Diagnostics.Process.Start("winword"); if (get == "rExcel") System.Diagnostics.Process.Start("excel"); string[] get_Split = get.Split('~'); int time = Convert.ToInt32(get_Split[1]); if (get.Contains("rshutdown")) { System.Diagnostics.Process.Start("shutdown", "-s -t " + time.ToString()); } }
When i use this code where the sring[] is on the front place i can´t open word! but i can shutdown the Pc in x sec!?string[] get_Split = get.Split('~'); int time = Convert.ToInt32(get_Split[1]); if (get.Contains("rshutdown")) { System.Diagnostics.Process.Start("shutdown", "-s -t " + time.ToString()); } } if (get == "rWord") System.Diagnostics.Process.Start("winword"); if (get == "rExcel") System.Diagnostics.Process.Start("excel");
Why is that so that only the one command work? -
It´s difficut to explain it! I have a Server and a Client. the Client have many Buttons for examble open Word , shutdown,... When i use this code in the Server i can click on open Word or shutdown both works!
if (get == "rWord") System.Diagnostics.Process.Start("winword"); if (get == "rExcel") System.Diagnostics.Process.Start("excel"); string[] get_Split = get.Split('~'); int time = Convert.ToInt32(get_Split[1]); if (get.Contains("rshutdown")) { System.Diagnostics.Process.Start("shutdown", "-s -t " + time.ToString()); } }
When i use this code where the sring[] is on the front place i can´t open word! but i can shutdown the Pc in x sec!?string[] get_Split = get.Split('~'); int time = Convert.ToInt32(get_Split[1]); if (get.Contains("rshutdown")) { System.Diagnostics.Process.Start("shutdown", "-s -t " + time.ToString()); } } if (get == "rWord") System.Diagnostics.Process.Start("winword"); if (get == "rExcel") System.Diagnostics.Process.Start("excel");
Why is that so that only the one command work?PC17 wrote:
It´s difficut to explain it!
I can't imagine why it would be difficult. Just give us the facts, with all the relevant details, and you'll get an answer. Read my sig. Here are just a few of the unclear points: - are client and server on the same machine? if not: - where is winword or excel to run? how is the client involved? - which machine should shutdown? the server? can any client tell the server to shutdown? And you should publish code inside PRE tags, that way you would have seen yourself that at least one of your code snippets will not even compile. Read my sig. :)
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
-
It´s difficut to explain it! I have a Server and a Client. the Client have many Buttons for examble open Word , shutdown,... When i use this code in the Server i can click on open Word or shutdown both works!
if (get == "rWord") System.Diagnostics.Process.Start("winword"); if (get == "rExcel") System.Diagnostics.Process.Start("excel"); string[] get_Split = get.Split('~'); int time = Convert.ToInt32(get_Split[1]); if (get.Contains("rshutdown")) { System.Diagnostics.Process.Start("shutdown", "-s -t " + time.ToString()); } }
When i use this code where the sring[] is on the front place i can´t open word! but i can shutdown the Pc in x sec!?string[] get_Split = get.Split('~'); int time = Convert.ToInt32(get_Split[1]); if (get.Contains("rshutdown")) { System.Diagnostics.Process.Start("shutdown", "-s -t " + time.ToString()); } } if (get == "rWord") System.Diagnostics.Process.Start("winword"); if (get == "rExcel") System.Diagnostics.Process.Start("excel");
Why is that so that only the one command work?Aha! Now I understand. The problem is with these lines
string\[\] get\_Split = get.Split('~'); int time = Convert.ToInt32(get\_Split\[1\]);
Take the example of starting word.
get
is "rWord" get_Split will have length 1 ie:get_Split[0]
= "rWord" the lineint time = Convert.ToInt32(get_Split[1]);
tries to access an array element that doesn't existget_Split[1]
, this will throw an error. This will workif (get == "rWord")
System.Diagnostics.Process.Start("winword");
if (get == "rExcel")
System.Diagnostics.Process.Start("excel");
if (get.Contains("rshutdown"))
{
string[] get_Split = get.Split('~');
int time = Convert.ToInt32(get_Split[1]);
System.Diagnostics.Process.Start("shutdown", "-s -t " + time.ToString());
} -
It´s difficut to explain it! I have a Server and a Client. the Client have many Buttons for examble open Word , shutdown,... When i use this code in the Server i can click on open Word or shutdown both works!
if (get == "rWord") System.Diagnostics.Process.Start("winword"); if (get == "rExcel") System.Diagnostics.Process.Start("excel"); string[] get_Split = get.Split('~'); int time = Convert.ToInt32(get_Split[1]); if (get.Contains("rshutdown")) { System.Diagnostics.Process.Start("shutdown", "-s -t " + time.ToString()); } }
When i use this code where the sring[] is on the front place i can´t open word! but i can shutdown the Pc in x sec!?string[] get_Split = get.Split('~'); int time = Convert.ToInt32(get_Split[1]); if (get.Contains("rshutdown")) { System.Diagnostics.Process.Start("shutdown", "-s -t " + time.ToString()); } } if (get == "rWord") System.Diagnostics.Process.Start("winword"); if (get == "rExcel") System.Diagnostics.Process.Start("excel");
Why is that so that only the one command work?The two pieces of code aren't actually the same. You haven't just moved the string[] array, you've also moved the second
}
. Try this to see if it has any effect:string[] get_Split = get.Split('~');
int time = Convert.ToInt32(get_Split[1]);
if (get.Contains("rshutdown"))
{
System.Diagnostics.Process.Start("shutdown", "-s -t " + time.ToString());
}
if (get == "rWord")
System.Diagnostics.Process.Start("winword");
if (get == "rExcel")
System.Diagnostics.Process.Start("excel");
}"WPF has many lovers. It's a veritable porn star!" - Josh Smith
As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
-
The two pieces of code aren't actually the same. You haven't just moved the string[] array, you've also moved the second
}
. Try this to see if it has any effect:string[] get_Split = get.Split('~');
int time = Convert.ToInt32(get_Split[1]);
if (get.Contains("rshutdown"))
{
System.Diagnostics.Process.Start("shutdown", "-s -t " + time.ToString());
}
if (get == "rWord")
System.Diagnostics.Process.Start("winword");
if (get == "rExcel")
System.Diagnostics.Process.Start("excel");
}"WPF has many lovers. It's a veritable porn star!" - Josh Smith
As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
@keefb Thank you, you have understand my problem! now i can open Word and so when i put the code on the Front place! But now this code doesn´t work! if (get == "rshutdown_without_warning") System.Diagnostics.Process.Start("shutdown", "-s -t 0"); if (get == "rshutdown_abort") System.Diagnostics.Process.Start("shutdown", "-a"); thank you at all!!! EDIT: I don´t know why but it works! Thank you at everybody, it´s a very good forum, there are a lot of very clever people! :thumbsup::thumbsup:
modified on Thursday, August 20, 2009 4:22 PM