CLR: .Net / Mono / Boo / Otros CLR > C#

 Pequeña Pregunta

(1/1)

menska:
Buenas, tengo una duda existencial sobre como ejecutar una aplicación desde C#.

  Yo lo que hago es abrir una ventana de sistema en el directorio donde está la aplicación y la abro, pero queda ahí la ventana de consola y no es muy estético que digamos....

  No sé... Y para abrir un .html (en local) en el IE??

  Gracias!  :hola:

desgraciado:
puedes usar System.Diagnostics.ProcessStartInfo, System.Diagnostics.Process
que es equivalente a system() C++

esto lo saque de la MSDN


--- Código: Text --- using System;using System.Diagnostics;using System.ComponentModel; namespace MyProcessSample{    /// <summary>    /// Shell for the sample.    /// </summary>    public class MyProcess    {               /// <summary>        /// Opens the Internet Explorer application.        /// </summary>        public void OpenApplication(string myFavoritesPath)        {            // Start Internet Explorer. Defaults to the home page.            Process.Start("IExplore.exe");                                // Display the contents of the favorites folder in the browser.            Process.Start(myFavoritesPath);         }                /// <summary>        /// Opens urls and .html documents using Internet Explorer.        /// </summary>        public void OpenWithArguments()        {            // url's are not considered documents. They can only be opened            // by passing them as arguments.            Process.Start("IExplore.exe", "www.northwindtraders.com");                        // Start a Web page using a browser associated with .html and .asp files.            Process.Start("IExplore.exe", "C:\\myPath\\myFile.htm");            Process.Start("IExplore.exe", "C:\\myPath\\myFile.asp");        }                /// <summary>        /// Uses the ProcessStartInfo class to start new processes, both in a minimized         /// mode.        /// </summary>        public void OpenWithStartInfo()        {                        ProcessStartInfo startInfo = new ProcessStartInfo("IExplore.exe");            startInfo.WindowStyle = ProcessWindowStyle.Minimized;                        Process.Start(startInfo);                        startInfo.Arguments = "www.northwindtraders.com";                        Process.Start(startInfo);                    }         public static void Main()        {                    // Get the path that stores favorite links.                    string myFavoritesPath =                     Environment.GetFolderPath(Environment.SpecialFolder.Favorites);                                    MyProcess myProcess = new MyProcess();                     myProcess.OpenApplication(myFavoritesPath);            myProcess.OpenWithArguments();            myProcess.OpenWithStartInfo();          }        }}  

menska:
Gracias por tu ayuda... desgraciado (gegege, que nick :P ). Lo probaré!

Johan Hernandez:
Si necesitas direccionar el Stream de salida,error de una aplicacion como IE, utilizar la redireccion de Streams en la clase ProcessStartInfo + un hilo que espere mientras Stream.ReadLine() te devuelve cada linea que ese proceso manda a traves de su Stream de salida, en.NET, Console.WriteLine(). :)

Navegación

[0] Índice de Mensajes

Ir a la versión completa