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 }
  • 相关阅读:
    LAMP LNMP 和 LNMPA
    nginx版本如何选择?
    如何看apache的版本号
    CLR Via CSharp读书笔记(12):泛型
    要先怀疑外部代码的错误,再检测是不是自己代码的问题
    redis的那些事
    An Illustrated Guide to SSH Agent Forwarding
    Using sshagent with ssh
    dtach
    [原创]bind DNS IP列表的精确获取
  • 原文地址:https://www.cnblogs.com/geosnoob/p/14330324.html
Copyright © 2011-2022 走看看