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>

  • 相关阅读:
    汉诺塔
    协变和逆变随笔
    NetCore开发第一步 Log4Net日志引入
    插入排序算法
    选择排序算法
    冒泡排序算法
    排序算法
    线性链表
    SAN
    SAM -- Chap 8 提升方法 自我梳理
  • 原文地址:https://www.cnblogs.com/chuncn/p/5876692.html
Copyright © 2011-2022 走看看