Click here to Skip to main content
15,905,508 members
Home / Discussions / C#
   

C#

 
QuestionFile Convert .DOCX to .png Pin
raushan_91-Feb-11 1:32
raushan_91-Feb-11 1:32 
AnswerRe: File Convert .DOCX to .png Pin
JF20151-Feb-11 2:18
JF20151-Feb-11 2:18 
AnswerRe: File Convert .DOCX to .png Pin
Eddy Vluggen1-Feb-11 6:57
professionalEddy Vluggen1-Feb-11 6:57 
GeneralRe: File Convert .DOCX to .png Pin
raushan_91-Feb-11 8:02
raushan_91-Feb-11 8:02 
GeneralRe: File Convert .DOCX to .png Pin
Eddy Vluggen1-Feb-11 20:27
professionalEddy Vluggen1-Feb-11 20:27 
Questioncheck if value is null Pin
arkiboys1-Feb-11 1:01
arkiboys1-Feb-11 1:01 
AnswerRe: check if value is null Pin
Bernhard Hiller1-Feb-11 1:09
Bernhard Hiller1-Feb-11 1:09 
GeneralRe: check if value is null Pin
arkiboys1-Feb-11 1:12
arkiboys1-Feb-11 1:12 
GeneralRe: check if value is null Pin
Dave Kreskowiak1-Feb-11 1:53
mveDave Kreskowiak1-Feb-11 1:53 
AnswerRe: check if value is null Pin
Richard MacCutchan1-Feb-11 1:10
mveRichard MacCutchan1-Feb-11 1:10 
GeneralRe: check if value is null Pin
arkiboys1-Feb-11 1:28
arkiboys1-Feb-11 1:28 
GeneralRe: check if value is null Pin
Pete O'Hanlon1-Feb-11 1:43
mvePete O'Hanlon1-Feb-11 1:43 
GeneralRe: check if value is null Pin
arkiboys1-Feb-11 1:50
arkiboys1-Feb-11 1:50 
GeneralRe: check if value is null Pin
Richard MacCutchan1-Feb-11 3:19
mveRichard MacCutchan1-Feb-11 3:19 
QuestionGetWindowText Funcation not working Fine iF Application Title is Unicode or Other Language. Pin
Anubhava Dimri1-Feb-11 0:17
Anubhava Dimri1-Feb-11 0:17 
AnswerRe: GetWindowText Funcation not working Fine iF Application Title is Unicode or Other Language. Pin
Pete O'Hanlon1-Feb-11 0:22
mvePete O'Hanlon1-Feb-11 0:22 
GeneralRe: GetWindowText Funcation not working Fine iF Application Title is Unicode or Other Language. Pin
Anubhava Dimri1-Feb-11 0:46
Anubhava Dimri1-Feb-11 0:46 
GeneralRe: GetWindowText Funcation not working Fine iF Application Title is Unicode or Other Language. Pin
Richard MacCutchan1-Feb-11 1:08
mveRichard MacCutchan1-Feb-11 1:08 
GeneralRe: GetWindowText Funcation not working Fine iF Application Title is Unicode or Other Language. Pin
Anubhava Dimri1-Feb-11 19:17
Anubhava Dimri1-Feb-11 19:17 
GeneralRe: GetWindowText Funcation not working Fine iF Application Title is Unicode or Other Language. Pin
Richard MacCutchan1-Feb-11 22:04
mveRichard MacCutchan1-Feb-11 22:04 
GeneralRe: GetWindowText Funcation not working Fine iF Application Title is Unicode or Other Language. Pin
Pete O'Hanlon1-Feb-11 1:26
mvePete O'Hanlon1-Feb-11 1:26 
QuestionProblem executing Comman-line command - Need to press Ctrl+C to stop it ! Pin
All Time Programming31-Jan-11 22:23
All Time Programming31-Jan-11 22:23 
Hello,

I want to execute a command line command from my C#. I have written code that works but am not as expected. The code is taken from "How to Execute a Command in C# ?" found on this site. and is :
<code>
public static int ExecuteCommand(string Command, int Timeout)
{
int ExitCode = -1;
ProcessStartInfo ProcessInfo;
Process Process;
try
{
ProcessInfo = new ProcessStartInfo("cmd.exe", "/C " + Command);
ProcessInfo.UseShellExecute = false;
ProcessInfo.RedirectStandardOutput = true;
//ProcessInfo.CreateNoWindow = false;
//ProcessInfo.UseShellExecute = false;
Process = Process.Start(ProcessInfo);

// Get the results
string result = Process.StandardOutput.ReadToEnd();
Console.WriteLine("Process Result = " + result);
Process.WaitForExit();
ExitCode = Process.ExitCode;
Console.WriteLine("%%%%%%%%%%% EXIT CODE = " + ExitCode);
Process.Close();
}
catch (Exception e) {
Console.WriteLine("Error Processing ExecuteCommand : " + e.Message);
}
finally {
//Process = null;
//ProcessInfo = null;
}
return ExitCode;
}
</code>

The code runs, but untill I don't press "Ctrl+C" on dos prompt I don't see any results. I also want to check a line form the console text. For eg: If I find "Connected" from the output I want to close the process and return. Then when the user asks for disconnecting want to execute another command to disconnect the running application.

Why does the above code doesn't retun untill I press "Ctrl+c" on the command window (I don't want to show the command window also, right now am just showing)? Whne I press Ctrl+C I see the text on Console (output window), but want to check the text and on findling "Connected" want ot return and/or close the process.

Can anyone point out where am I going wrong and how to solve the problem and work out with it.

Any help is highly appreciated. Need to solve this early have already spend 2-3 days trying to solve the problem.

Thanks


Thanks & Regards,


AnswerRe: Problem executing Comman-line command - Need to press Ctrl+C to stop it ! Pin
JF201531-Jan-11 22:56
JF201531-Jan-11 22:56 
GeneralRe: Problem executing Comman-line command - Need to press Ctrl+C to stop it ! Pin
All Time Programming31-Jan-11 23:02
All Time Programming31-Jan-11 23:02 
QuestionBlock Windows "Guest" account Pin
marca29231-Jan-11 21:00
marca29231-Jan-11 21:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.