zoukankan      html  css  js  c++  java
  • C# 调用 python脚本

    https://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#//000100000m0s000000

    C# 调用 python脚本

     1 // Executes a shell command synchronously.
     2 // Example of command parameter value is
     3 // "python " + @"C:scriptsgeom_input.py".
     4 //
     5 public static void ExecuteCommand(object command)
     6 {
     7     try
     8     {
     9         // Create the ProcessStartInfo using "cmd" as the program to be run,
    10         // and "/c " as the parameters.
    11         // "/c" tells cmd that you want it to execute the command that follows,
    12         // then exit.
    13         System.Diagnostics.ProcessStartInfo procStartInfo = new
    14             System.Diagnostics.ProcessStartInfo("cmd", "/c " + command);
    15 
    16         // The following commands are needed to redirect the standard output.
    17         // This means that it will be redirected to the Process.StandardOutput StreamReader.
    18         procStartInfo.RedirectStandardOutput = true;
    19         procStartInfo.UseShellExecute = false;
    20 
    21         // Do not create the black window.
    22         procStartInfo.CreateNoWindow = true;
    23 
    24         // Now you create a process, assign its ProcessStartInfo, and start it.
    25         System.Diagnostics.Process proc = new System.Diagnostics.Process();
    26         proc.StartInfo = procStartInfo;
    27         proc.Start();
    28 
    29         // Get the output into a string.
    30         string result = proc.StandardOutput.ReadToEnd();
    31 
    32         // Display the command output.
    33         Console.WriteLine(result);
    34     }
    35     catch (Exception objException)
    36     {
    37         Console.WriteLine(objException.Message);
    38         // Log the exception and errors.
    39     }
    40 }
  • 相关阅读:
    fish shell version
    golang io.ReadFull
    Unity5 2D Animation
    unity3d vscode
    golang bufio.Scanner
    kafka知识点
    linux clone
    Oracle查询在哪些 存储过程/函数/触发器 等等中包含 指定字符串
    在Oracle中,使用简洁的函数(Function)实现字符串split分割效果
    在Spring中,使用ProxyFactory实现对Cglib代理对象的再次代理
  • 原文地址:https://www.cnblogs.com/geosnoob/p/14330324.html
Copyright © 2011-2022 走看看