|
|
|
马上加入,结交更多好友,共享更多资料,让你轻松玩转电力研学社区!
您需要 登录 才可以下载或查看,没有账号?立即加入
×
程序功能主要是:读入已知文件,调用外部程序pfnt.exe进行相关的计算,然后把程序计算的结果以文档形式进行输出。但在运行到info.start()时,出现“系统找不到指定的文件”这个错误,请大虾指教!!!
' ^! a( B1 o4 z( w! e: z: N# L% u X% p4 |# [. A
using System;
3 \, p) f# B. qusing System.Collections.Generic;
9 J; n* D5 |2 Fusing System.Text;
! G! _4 E5 l+ f w3 wusing System.Diagnostics;+ `- f% k* g, _
using System.IO;$ G& S( V) G5 L: \' t
3 X/ X6 K+ I7 I: l' x% b' C [3 g& I
namespace ConsoleApplication28; @9 V y( D( ?% R- q
{
1 h% [& a+ [, |: V0 I class Program
# I; {- I* H; \9 K {
* \ N) @' [, c2 l$ s) ] static void Main(string[] args)' {0 [+ R. q* K
{/ b1 D% D; c0 y5 L" H% M/ M$ e1 y
Process info = new Process();, N) Q2 F$ w4 @) q$ Z8 t
info.StartInfo.FileName = "pfnt.exe";( n) S# ]( H5 V
info.StartInfo.Arguments = @"E:\广东电网充裕度评估系统\BPA数据\2008年底大(正常潮流).dat";//原始数据文件路径
+ j3 l/ K' g* F, @1 ` i info.StartInfo.WorkingDirectory = @"C:\psap32\BIN";//pfnt。exe程序路径+ \- b3 z1 o$ S- N4 M+ h0 [0 }
info.StartInfo.UseShellExecute = false;' S) ^7 l# ^3 z# H$ G
info.StartInfo.RedirectStandardInput = true;
1 I% s* |, C! u) p2 Y( k' x3 g1 Q info.StartInfo.RedirectStandardOutput = true;6 [5 ?+ `- M; n7 P3 N. I
info.Start();! u5 D' a7 d, g$ K
StreamReader sr = info.StandardOutput;; ^9 Q. X$ r% i/ E, S# j+ n
StreamWriter sw = new StreamWriter(@"E:\广东电网充裕度评估系统\童—潮流计算程序\powerflow.txt");//生成文档存放位置, r* j# Z- K9 W7 v
sw.Write(sr.ReadToEnd());- g$ Z$ L$ r7 Q* U. L( M/ }
sw.Close();
+ R2 }9 s! L) K( M* d }
8 d8 a5 v; p7 i: h2 t- h }
. R* A C `5 @( X& H8 n% A} |
|