马上加入,结交更多好友,共享更多资料,让你轻松玩转电力研学社区!
您需要 登录 才可以下载或查看,没有账号?立即加入
×
程序功能主要是:读入已知文件,调用外部程序pfnt.exe进行相关的计算,然后把程序计算的结果以文档形式进行输出。但在运行到info.start()时,出现“系统找不到指定的文件”这个错误,请大虾指教!!!
9 `) t- ]! w" o1 Y6 B) s! U/ _: @0 B0 z9 Y" a; B9 l4 ]
using System;: b( ], ~) X( k
using System.Collections.Generic;' o" i' _% k( r
using System.Text;( G3 Z: M4 Y- {, I
using System.Diagnostics;
# h; ?+ n; @* \7 y: E, [' nusing System.IO;
) s8 `" _4 Q8 u+ _6 ?: ~6 t
. o* Q9 x/ c5 B: X) X0 wnamespace ConsoleApplication28
( m1 J2 D7 P7 f! x) k6 ~2 t/ P8 F{
( h! \& a% K8 V class Program
, v6 A7 i- a& w! v' O {
6 v: v3 K9 r9 Z6 V* P static void Main(string[] args)2 i' J) l( W# h5 H
{$ v1 R# l& P, ?/ h$ ~6 M9 N4 M0 M
Process info = new Process();
6 k2 A) b) j3 `: |/ u% w6 W9 ~ info.StartInfo.FileName = "pfnt.exe";
0 k: x5 z6 ]1 _: y1 _8 {% X5 n info.StartInfo.Arguments = @"E:\广东电网充裕度评估系统\BPA数据\2008年底大(正常潮流).dat";//原始数据文件路径
. ?) J& E- G _$ t+ W2 a' h info.StartInfo.WorkingDirectory = @"C:\psap32\BIN";//pfnt。exe程序路径0 d* a+ k$ n$ k. O! Z8 A+ {3 v
info.StartInfo.UseShellExecute = false;) S& j: T4 f+ H
info.StartInfo.RedirectStandardInput = true;
3 [* T; p$ S! B- [ j) r, J) H, h info.StartInfo.RedirectStandardOutput = true;, Y+ I- T" v e, [# Q
info.Start();
" L- V/ r" t7 H StreamReader sr = info.StandardOutput;1 t, g" m! L/ |
StreamWriter sw = new StreamWriter(@"E:\广东电网充裕度评估系统\童—潮流计算程序\powerflow.txt");//生成文档存放位置
5 O! {8 Q; a2 A) R3 f# _ sw.Write(sr.ReadToEnd());! o" A7 b, g" C. v- |; f5 x' q
sw.Close();
) w* C" S/ H" g5 h4 w }2 H* u' a( L9 a: c. a, r% R
}
( N# V$ B" Z4 Q3 L3 `' u} |