Geeks With Blogs

News


Rodney Vinyard - .NET & SQL Developer When all is said and done, more will be said than done

        protected void Button1_Click(object sender, EventArgs e)

        {

            string executePath = System.Configuration.ConfigurationSettings.AppSettings["executePath"];

            ExecuteCommandSync(executePath);

 

            string resultfilePath = System.Configuration.ConfigurationSettings.AppSettings["filePath"];

 

            this.Label1.Text = System.IO.File.ReadAllText(resultfilePath);

 

        }

        public void ExecuteCommandSync(string executePath)

        {

            try

            {

                System.Diagnostics.Process p = new System.Diagnostics.Process(); // Redirect the output stream of the child process.

                p.StartInfo.UseShellExecute = false;

                p.StartInfo.RedirectStandardOutput = true;

                p.StartInfo.FileName = executePath;

                p.Start(); // Do not wait for the child process to exit before // reading to the end of its redirected stream. // p.WaitForExit(); // Read the output stream first and then wait. string output = p.StandardOutput.ReadToEnd(); p.WaitForExit();

                p.WaitForExit();

            }

            catch (Exception ex)

            {

                System.Diagnostics.Debug.WriteLine(ex.ToString());

            }

 

        }

Posted on Tuesday, May 5, 2009 7:21 AM miscellaneous | Back to top


Comments on this post: Shell to a process and wait synchronously

# re: Shell to a process and wait synchronously
Requesting Gravatar...
Dresses, evening, cocktail, prom dresses, formal gowns from eiDress. Homecoming dresses and bridesmaid.Evening Dresses
Cocktail Dresses
Left by GG on Mar 29, 2010 12:07 AM

# re: Shell to a process and wait synchronously
Requesting Gravatar...
well explained code..
Evening Dresses | Discount Evening Dresses
Left by mark on May 06, 2010 1:12 PM

# re: Shell to a process and wait synchronously
Requesting Gravatar...
I dont know what to say. This blog is fantastic. Thats not really a really huge statement
Left by air jordan sneakers sale on Dec 18, 2010 1:50 AM

Your comment:
 (will show your gravatar)


Copyright © Rodney Vinyard | Powered by: GeeksWithBlogs.net