C#中调用外部程序,把结果以文档形式输出
程序功能主要是:读入已知文件,调用外部程序pfnt.exe进行相关的计算,然后把程序计算的结果以文档形式进行输出。但在运行到info.start()时,出现“系统找不到指定的文件”这个错误,请大虾指教!!!using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using System.IO;
namespace ConsoleApplication28
{
class Program
{
static void Main(string[] args)
{
Process info = new Process();
info.StartInfo.FileName = "pfnt.exe";
info.StartInfo.Arguments = @"E:\广东电网充裕度评估系统\BPA数据\2008年底大(正常潮流).dat";//原始数据文件路径
info.StartInfo.WorkingDirectory = @"C:\psap32\BIN";//pfnt。exe程序路径
info.StartInfo.UseShellExecute = false;
info.StartInfo.RedirectStandardInput = true;
info.StartInfo.RedirectStandardOutput = true;
info.Start();
StreamReader sr = info.StandardOutput;
StreamWriter sw = new StreamWriter(@"E:\广东电网充裕度评估系统\童—潮流计算程序\powerflow.txt");//生成文档存放位置
sw.Write(sr.ReadToEnd());
sw.Close();
}
}
} 呵呵,不懂编程 呵呵,下载看看 我最近也在用c#调用一些程序,有空和楼主交流下啊 最近在用MATLAB做这个 info.StartInfo.FileName =System.Environment.CurrentDirectory+ @"\pfnt.exe"
对pfnt.exe应该加一个路径
页:
[1]