当前位置: 首页>>代码示例>>C#>>正文


C# Process.Start方法代码示例

本文整理汇总了C#中Process.Start方法的典型用法代码示例。如果您正苦于以下问题:C# Process.Start方法的具体用法?C# Process.Start怎么用?C# Process.Start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Process的用法示例。


在下文中一共展示了Process.Start方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

    static void Main()
    {
        try
        {
            string[] words = { "start", "Start - Game", "end - GameStart" };
            string txtFile = @"..\..\textFile.txt";
            string outputFile = @"..\..\finish.txt";

            RandomizationFile(words, txtFile);
            ChangingWordInFile(txtFile, outputFile);

            Process openfile = new Process();
            openfile.StartInfo.FileName = txtFile;
            openfile.Start();

            openfile.StartInfo.FileName = outputFile;
            openfile.Start();
        }
        catch (FileNotFoundException FNFE)
        {
            Console.WriteLine(FNFE.Message);
        }
        catch (NullReferenceException NRE)
        {
            Console.WriteLine(NRE.Message);
        }
        catch (ArgumentNullException ANE)
        {
            Console.WriteLine(ANE.Message);
        }
        finally
        {
            Console.WriteLine("Good Bye");
        }
    }
开发者ID:joro1881,项目名称:CSharpProgramming,代码行数:35,代码来源:Modifying07.cs

示例2: Main

    static void Main()
    {
        string fileName = "testFile.txt";
        string resultFileName = "resultFile.txt";
        Random randomGenerator = new Random();

        List<string> words = new List<string>(66);
        GenerateWords(words);

        StreamWriter writer = new StreamWriter(fileName, false, Encoding.GetEncoding("windows-1251"));
        using (writer)
        {
            for (int i = 0; i < 200; i++)
            {
                switch (randomGenerator.Next(5))
                {
                    case 0:
                        writer.Write(words[0]);
                        break;
                    case 1:
                        writer.Write(words[1]);
                        break;
                    case 2:
                        writer.Write(words[2]);
                        break;
                    default:
                        writer.Write(words[randomGenerator.Next(words.Count)]);
                        break;
                }
            }
        }

        writer = new StreamWriter(resultFileName, false, Encoding.GetEncoding("windows-1251"));
        StreamReader reader = new StreamReader(fileName, Encoding.GetEncoding("windows-1251"));
        using (writer)
        {
            using (reader)
            {
                string line = reader.ReadLine();
                while (line != null)
                {
                    line = Regex.Replace(line, @"(\b)test((\d|\w|_)*)(\b)", " ");
                    writer.WriteLine(Regex.Replace(line, @"(\s){2,}", " "));
                    line = reader.ReadLine();
                }
            }
        }


        Process openFile = new Process();
        openFile.StartInfo.FileName = fileName;
        openFile.Start();

        openFile.StartInfo.FileName = resultFileName;
        openFile.Start();
    }
开发者ID:Nottyy,项目名称:TelerikAcademy,代码行数:56,代码来源:DeleteWordsStartingWithGivenPrefix.cs

示例3: BuildGame

    public static void BuildGame()
    {
        // Get filename.
        string path = "C:/builds/";
        string date = DateTime.Now.ToString("HHmm_dd_MM_yyyy");
        string fullpath = path + date;
        Directory.CreateDirectory(fullpath);

        //string path = EditorUtility.SaveFolderPanel("Choose Location of Built Game", "", "");
        string[] levels = new string[] { "Assets/Scenes/main.unity" };




        // Build player.
        //Debug.Log("Starting Build");
        BuildPipeline.BuildPlayer(levels, fullpath + "/build.exe", BuildTarget.StandaloneWindows, BuildOptions.None);

        // Copy a file from the project folder to the build folder, alongside the built game.
        //FileUtil.CopyFileOrDirectory("Assets/WebPlayerTemplates/Readme.txt", path + "Readme.txt");

        // Run the game (Process class from System.Diagnostics).
        Process proc = new Process();
        proc.StartInfo.FileName = fullpath + "/build.exe";
        proc.Start();
    }
开发者ID:JRSerjeant,项目名称:GGJ2016,代码行数:26,代码来源:WindowsBuildWithPostprocess.cs

示例4: ConvertFromUrl

    public void ConvertFromUrl(string url, string file_out, HtmlToImageConverterOptions options)
    {
        string converter_path = HttpContext.Current.Server.MapPath ("~/bin/wkhtmltopdf/wkhtmltoimage.exe");

        string param_options = null;

        if (options != null)
        {
            StringBuilder sb_params = new StringBuilder();

            if (options.CropWidth > 0) sb_params.Append(" --crop-w ").Append(options.CropWidth);
            if (options.CropHeight > 0) sb_params.Append(" --crop-h ").Append(options.CropHeight);
            if (options.Quality > 0) sb_params.Append(" --quality ").Append(options.Quality);
            if (!string.IsNullOrEmpty(options.CookieName)) sb_params.Append(" --cookie ").Append(options.CookieName).Append(' ').Append(options.CookieValue);

            param_options = sb_params.ToString();
        }

        ProcessStartInfo psi = new ProcessStartInfo(converter_path, string.Format("{0} \"{1}\" \"{2}\"", param_options.Trim(), url, file_out));

        psi.UseShellExecute = false;
        psi.CreateNoWindow = true;

        Process proc = new Process();
        proc.StartInfo = psi;
        proc.Start();

        proc.WaitForExit();
    }
开发者ID:publichealthcloud,项目名称:absenteesurveillance,代码行数:29,代码来源:HtmlToImage.cs

示例5: RunProcess

	static bool RunProcess (string runtimeEngine, int numLines)
	{
		string stderr, stdout;
		sb = new StringBuilder ();

		string program = Path.Combine (AppDomain.CurrentDomain.BaseDirectory,
			"output.exe");

		Process proc = new Process ();
		if (!string.IsNullOrEmpty (runtimeEngine)) {
			proc.StartInfo.FileName = runtimeEngine;
			proc.StartInfo.Arguments = string.Format (CultureInfo.InvariantCulture,
				"\"{0}\" {1}", program, numLines);
		} else {
			proc.StartInfo.FileName = program;
			proc.StartInfo.Arguments = string.Format (CultureInfo.InvariantCulture,
				 "{0}", numLines);
		}
		proc.StartInfo.UseShellExecute = false;
		proc.StartInfo.RedirectStandardOutput = true;
		proc.StartInfo.RedirectStandardError = true;
		proc.OutputDataReceived += new DataReceivedEventHandler (OutputHandler);
		proc.Start ();

		proc.BeginOutputReadLine ();
		stderr = proc.StandardError.ReadToEnd ();
		proc.WaitForExit ();

		stdout = sb.ToString ();

		string expectedResult = "STDOUT => 1" + Environment.NewLine +
			"STDOUT => 2" + Environment.NewLine + "STDOUT => 3" +
			Environment.NewLine + "STDOUT => 4" + Environment.NewLine +
			" " + Environment.NewLine + "STDOUT => 6" + Environment.NewLine +
			"STDOUT => 7" + Environment.NewLine + "STDOUT => 8" +
			Environment.NewLine + "STDOUT => 9" + Environment.NewLine;
		if (stdout != expectedResult) {
			Console.WriteLine ("expected:");
			Console.WriteLine (expectedResult);
			Console.WriteLine ("was:");
			Console.WriteLine (stdout);
			return false;
		}

		expectedResult = "STDERR => 1" + Environment.NewLine +
			"STDERR => 2" + Environment.NewLine + "STDERR => 3" +
			Environment.NewLine + "STDERR => 4" + Environment.NewLine +
			" " + Environment.NewLine + "STDERR => 6" + Environment.NewLine +
			"STDERR => 7" + Environment.NewLine + "STDERR => 8" +
			Environment.NewLine + "STDERR => 9" + Environment.NewLine;
		if (stderr != expectedResult) {
			Console.WriteLine ("expected:");
			Console.WriteLine (expectedResult);
			Console.WriteLine ("was:");
			Console.WriteLine (stderr);
			return false;
		}

		return true;
	}
开发者ID:mono,项目名称:gert,代码行数:60,代码来源:test.cs

示例6: StartProcess

    /// <summary>
    /// プロセスを実行
    /// </summary>
    public void StartProcess(ProcessData procData)
    {
        if(procData.use && !procData.IsRunning)
        {
            FileInfo fileInfo = new FileInfo(procData.exePath);
            if(fileInfo.Exists)
            {
                Process proc = new Process();
                proc.StartInfo.FileName = Path.GetFullPath(procData.exePath);

                //引数設定
                if(procData.argument != "")
                    proc.StartInfo.Arguments = procData.argument;

                //ウィンドウスタイル設定
                if(!ApplicationSetting.Instance.GetBool("IsDebug"))
                    proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;

                try
                {
                    proc.Start();

                    processList.Add(proc);
                    procData.IsRunning = true;
                }
                catch(Exception e)
                {
                    UnityEngine.Debug.Log("ExternalProcess :: process start error - " + e.Message);
                }
            }
        }
    }
开发者ID:sgyli7,项目名称:GarageKit_for_Unity,代码行数:35,代码来源:ExternalProcess.cs

示例7: StartAndKillProcessWithDelay

 protected void StartAndKillProcessWithDelay(Process p)
 {
     p.Start();
     Sleep();
     p.Kill();
     Assert.True(p.WaitForExit(WaitInMS));
 }
开发者ID:healtech,项目名称:corefx,代码行数:7,代码来源:ProcessTestBase.cs

示例8: Main

    public static void Main(String[] args)
    {
        String code = null;
        if (args.Length == 0) {
          Console.Write("Parse: ");
          code = Console.ReadLine();
        } else {
          if (args.Length == 1 && File.Exists(args[0])) {
        code = File.ReadAllText(args[0]);
          } else {
        code = String.Join(" ", args);
          }
        }

        code = code.Trim();

        var file = Path.GetTempFileName() + ".scala";
        if (!code.StartsWith("class") && !code.StartsWith("object") && !code.StartsWith("trait")) code = "object wrapper { " + code + " }";
        File.WriteAllText(file, code);
        var dir = Path.GetDirectoryName(file);
        var name = Path.GetFileName(file);

        var process = new Process();
        var scala = @"%SCRIPTS_HOME%\scalac.exe".Expand();
        process.StartInfo.FileName = scala;
        process.StartInfo.WorkingDirectory = dir;
        process.StartInfo.Arguments = "-language:experimental.macros -Xprint:parser -Yshow-trees -Yshow-trees-compact -Yshow-trees-stringified -Ystop-after:parser " + name;
        process.StartInfo.UseShellExecute = false;
        process.Start();
        process.WaitForExit();
    }
开发者ID:xeno-by,项目名称:dotwindows,代码行数:31,代码来源:parse.cs

示例9: onPostProcessBuildPlayer

    private static void onPostProcessBuildPlayer( BuildTarget target, string pathToBuiltProject )
    {
        if (target == BuildTarget.iOS) {
            UnityEngine.Debug.Log ("Heyzap: started post-build script");

            // grab the path to the postProcessor.py file
            var scriptPath = Path.Combine( Application.dataPath, "Editor/Heyzap/HeyzapPostprocessBuildPlayer.py" );

            // sanity check
            if( !File.Exists( scriptPath ) ) {
                UnityEngine.Debug.LogError( "HZ post builder couldn't find python file. Did you accidentally delete it?" );
                return;
            } else {
                var args = string.Format( "\"{0}\" \"{1}\"", scriptPath, pathToBuiltProject );
                var proc = new Process
                {
                    StartInfo = new ProcessStartInfo
                    {
                        FileName = "python2.6",
                        Arguments = args,
                        UseShellExecute = false,
                        RedirectStandardOutput = false,
                        CreateNoWindow = true
                    }
                };

                proc.Start();
                proc.WaitForExit();

                UnityEngine.Debug.Log( "Heyzap: Finished post-build script" );
            }
        }
    }
开发者ID:noahzaozao,项目名称:HeyzapDemoUnity,代码行数:33,代码来源:HeyzapPostBuild.cs

示例10: GetMXServers

    public IList<MXServer> GetMXServers(string domainName)
    {
        string command = "nslookup -q=mx " + domainName;
        ProcessStartInfo procStartInfo = new ProcessStartInfo("cmd", "/c " + command);

        procStartInfo.RedirectStandardOutput = true;
        procStartInfo.UseShellExecute = false;

        procStartInfo.CreateNoWindow = true;

        Process proc = new Process();
        proc.StartInfo = procStartInfo;
        proc.Start();
        string result = proc.StandardOutput.ReadToEnd();

        if (!string.IsNullOrEmpty(result))
            result = result.Replace("\r\n", Environment.NewLine);

        IList<MXServer> list = new List<MXServer>();
        foreach (string line in result.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries))
        {
            if (line.Contains("MX preference =") && line.Contains("mail exchanger ="))
            {
                MXServer mxServer = new MXServer();
                mxServer.Preference = Int(GetStringBetween(line, "MX preference = ", ","));
                mxServer.MailExchanger = GetStringFrom(line, "mail exchanger = ");

                list.Add(mxServer);
            }
          }
        return list.OrderBy(m => m.Preference).ToList();
    }
开发者ID:phonglam29305,项目名称:FAMail,代码行数:32,代码来源:Commander.cs

示例11: CheckGDAL

    public bool CheckGDAL()
    {
        try
        {
            string appPath = "gdalinfo";

            StreamReader str0 = StreamReader.Null;
            string output = "";
            Process prc = new Process();
            prc.StartInfo.FileName = appPath;
            prc.StartInfo.Arguments = "--version";
            prc.StartInfo.UseShellExecute = false;
            prc.StartInfo.CreateNoWindow = true;
            prc.StartInfo.RedirectStandardOutput = true;
            prc.Start();
            str0 = prc.StandardOutput;
            output = str0.ReadToEnd();
            prc.WaitForExit();
            str0.Close();

            string[] SubStrings = output.Split(' ');
            return (SubStrings[0] == "GDAL") ? true : false;

        }
        catch
        {
            return false;
        }
    }
开发者ID:kalxas,项目名称:GIMED,代码行数:29,代码来源:Program.cs

示例12: Test2

	static void Test2 (Process p)
	{
		ManualResetEvent mre_output = new ManualResetEvent (false);
		ManualResetEvent mre_error = new ManualResetEvent (false);

		p.Start ();

		p.OutputDataReceived += (s, a) => {
			if (a.Data == null) {
				mre_output.Set ();
				return;
			}
		};

		p.ErrorDataReceived += (s, a) => {
			if (a.Data == null) {
				mre_error.Set ();
				return;
			}
		};

		p.BeginOutputReadLine ();
		p.BeginErrorReadLine ();

		if (!p.WaitForExit (10000))
			Environment.Exit (4);
		if (!mre_output.WaitOne (1000))
			Environment.Exit (5);
		if (!mre_error.WaitOne (1000))
			Environment.Exit (6);
	}
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:31,代码来源:process-stress-3.cs

示例13: Test1

	static void Test1 (Process p)
	{
		ManualResetEvent mre_exit = new ManualResetEvent (false);
		ManualResetEvent mre_output = new ManualResetEvent (false);
		ManualResetEvent mre_error = new ManualResetEvent (false);

		p.EnableRaisingEvents = true;
		p.Exited += (s, a) => mre_exit.Set ();

		p.Start ();

		p.OutputDataReceived += (s, a) => {
			if (a.Data == null) {
				mre_output.Set ();
				return;
			}
		};

		p.ErrorDataReceived += (s, a) => {
			if (a.Data == null) {
				mre_error.Set ();
				return;
			}
		};

		p.BeginOutputReadLine ();
		p.BeginErrorReadLine ();

		if (!mre_exit.WaitOne (10000))
			Environment.Exit (1);
		if (!mre_output.WaitOne (1000))
			Environment.Exit (2);
		if (!mre_error.WaitOne (1000))
			Environment.Exit (3);
	}
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:35,代码来源:process-stress-3.cs

示例14: Execute

	public static int Execute(string CommandLineArgs )
	{
		int exitCode = 0 ; 
		try
		{
			Process process=new Process();
			process.StartInfo.FileName="xmlsign.exe" ; 
			process.StartInfo.UseShellExecute=false;
			process.StartInfo.RedirectStandardOutput=true;
			process.StartInfo.RedirectStandardInput=true;
			process.StartInfo.RedirectStandardError=true;
			process.StartInfo.CreateNoWindow=true;
			if( CommandLineArgs != null ) 
				process.StartInfo.Arguments = CommandLineArgs ; 
			process.Start();
			Console.WriteLine( process.StandardOutput.ReadToEnd() ) ; 
			process.WaitForExit();
			exitCode = process.ExitCode ; 
			process.Close();
		}
		catch(Exception e)
		{
			Console.WriteLine( e ) ; 
			exitCode = -1;
		}
		return exitCode ; 				
	}
开发者ID:koson,项目名称:.NETMF_for_LPC17xx,代码行数:27,代码来源:xmldsigtest.cs

示例15: ConvertFromUrl

    public void ConvertFromUrl(string url, string file_out, HtmlToPdfConverterOptions options)
    {
        string converter_path = HttpContext.Current.Server.MapPath("~/bin/wkhtmltopdf/wkhtmltopdf.exe");

        string param_options = null;

        if (options != null)
        {
            StringBuilder sb_params = new StringBuilder();

            if (!string.IsNullOrEmpty(options.Orientation)) sb_params.Append(" --orientation ").Append(options.Orientation);
            if (options.PageWidth > 0) sb_params.Append(" --page-width ").Append(options.PageWidth);
            if (options.PageHeight > 0) sb_params.Append(" --page-height ").Append(options.PageHeight);
            if (!string.IsNullOrEmpty(options.PageSize)) sb_params.Append(" --page-size ").Append(options.PageSize);
            if (!string.IsNullOrEmpty(options.CookieName)) sb_params.Append(" --cookie ").Append(options.CookieName).Append(' ').Append(options.CookieValue);

            param_options = sb_params.ToString();
        }

        ProcessStartInfo psi = new ProcessStartInfo(converter_path, string.Format("{0} \"{1}\" \"{2}\"", param_options.Trim(), url, file_out));

        psi.UseShellExecute = false;
        psi.CreateNoWindow = true;

        Process proc = new Process ();
        proc.StartInfo = psi;
        proc.Start();
        proc.WaitForExit();

        //!= 0) throw new Exception(string.Format("Could not generate {0}", file_out));
    }
开发者ID:publichealthcloud,项目名称:absenteesurveillance,代码行数:31,代码来源:HtmlToPdf.cs


注:本文中的Process.Start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。