- 积分
- 20677
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2011-7-16
- 最后登录
- 1970-1-1
|
发表于 2014-10-23 01:11:53
|
显示全部楼层
C#代码贴一下
using System;
using System.Windows.Forms;
using System.Diagnostics;
using System.IO;
namespace CallGrADS
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
//var workDir = Application.StartupPath;
const string workDir = @"c:\";
Environment.SetEnvironmentVariable("gaddir", workDir + @"\GrADS19\dat");
Environment.SetEnvironmentVariable("gascrp", workDir + @"\GrADS19\lib");
}
private void button1_Click(object sender, EventArgs e)
{
const string gsPath = @"D:\ZDZT\dat\gk14100708.gs";
if (File.Exists(gsPath))
{
var sr = new StreamReader(gsPath);
string gsFile = sr.ReadToEnd();
CallGrads(gsPath);
}
else
{
MessageBox.Show("gs文件不存在或有错误!");
}
}
private void CallGrads(string gsFile)
{
var info = new ProcessStartInfo
{
WindowStyle = ProcessWindowStyle.Hidden,
CreateNoWindow = true,
UseShellExecute = true,
WorkingDirectory = @"C:\GrADS19\win32\",
FileName = "grads.exe",
Arguments = string.Format(@"-blc {0}", gsFile)
};
try
{
var proc = Process.Start(info);
proc.WaitForExit(5000);
}
catch { }
}
}
} |
|