C#调用BPA
这是我写的一段小代码,就是调用BPA对指定的.dat文件计算一次潮流,代码如下using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
namespace 调用BPA
{
class Program
{
public class powerflow
{
public void powerflow1(string BPApath, string BPAdatapath) //BPApath 为BPA程序的存放路径,BPAdatapath为.dat数据文件的路径
{
Process dyBPA = new Process();
dyBPA.StartInfo.FileName = BPApath + "pfnt.exe";
dyBPA.StartInfo.Arguments = BPAdatapath;
dyBPA.StartInfo.UseShellExecute = false;
dyBPA.StartInfo.RedirectStandardInput = true;
dyBPA.StartInfo.RedirectStandardOutput = true;
dyBPA.StartInfo.CreateNoWindow = false;
dyBPA.StartInfo.WorkingDirectory = BPApath.Substring(0,BPApath.Length-1);
dyBPA.Start();
string output = dyBPA.StandardOutput.ReadToEnd();
dyBPA.Close();
}
}
static void Main(string[] args)
{
powerflow calculate = new powerflow();
calculate.powerflow1(@"C:\psap32\psaw", @"E:\广东电网充裕度评估系统\童—潮流计算程序\013bpa");
}
}
}
由于本人是刚刚学习,可能上面代码有许多错误,还请高手赐教~~~小弟不胜感激
页:
[1]