bravekiller 发表于 2010-5-4 21:48:26

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();
      }
    }
}

big_wong 发表于 2010-5-8 09:43:49

呵呵,不懂编程

caojun 发表于 2010-6-3 19:08:10

呵呵,下载看看

yilaozhuang 发表于 2010-6-3 19:40:24

我最近也在用c#调用一些程序,有空和楼主交流下啊

oozy1987 发表于 2010-6-7 10:22:04

最近在用MATLAB做这个

大猫骨 发表于 2011-3-24 15:03:31

info.StartInfo.FileName =System.Environment.CurrentDirectory+ @"\pfnt.exe"
对pfnt.exe应该加一个路径
页: [1]
查看完整版本: C#中调用外部程序,把结果以文档形式输出

招聘斑竹