zoukankan      html  css  js  c++  java
  • asp.net中调用命令行

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication2.WebForm1" %>
    <%@ Import Namespace="System.Diagnostics" %>
    <script runat="server">
    protected override void OnInit(EventArgs e)
    {
    string filePath = @"C:WindowsMicrosoft.NETFrameworkv4.0.30319msbuild.exe";
    string param = @" E:DevCNBlogsJob.sln /p:Configuration=release";

    filePath = "notepad.exe";
    param = "";

    //以release方式编译CNBlogsJob.sln
    ProcessStartInfo info = new ProcessStartInfo(filePath, param);
    //将控制台输出重定向至StandardOutput,如果为false,就无法得到控制台输出结果
    info.RedirectStandardOutput = true;
    info.UseShellExecute = false;
    Process p = Process.Start(info);
    //下面一行代码是为了模拟控制台的显示效果
    Response.Write("<body style="color:#DDD;background-color:#000;">");
    //控制台输出结果
    Response.Write(p.StandardOutput.ReadToEnd().Replace(" ","<br/>"));
    Response.Write("</body>");
    p.WaitForExit();
    p.Close();
    }
    </script>
    <!DOCTYPE html>

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
    </head>
    <body>
    <form id="form1" runat="server">
    <div>

    </div>
    </form>
    </body>
    </html>

  • 相关阅读:
    子数组的最大乘积
    重建二叉树
    只考加法的面试题
    找出发帖的水王问题
    寻找最近点对
    寻找最大的k个数问题
    寻找数组中 的最大值最小值
    数组中的最长递增子序列
    常用的百度API地图操作
    div 背景自适应
  • 原文地址:https://www.cnblogs.com/chuncn/p/5876692.html
Copyright © 2011-2022 走看看