- 积分
- 42203
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2012-3-5
- 最后登录
- 1970-1-1
|
发表于 2013-3-28 04:53:04
|
显示全部楼层
合并NC文件,如果是二次开发,可以使用MeteoInfoC中的函数查看要合并的nc文件信息,然后使用nco中的命令做实际工作(http://nco.sourceforge.net/)。
上个函数,贴点代码。 这里代码的功能是将新产生的小文件不停地append已有的文件后面。 /// fileout = fileout + filein;
private void UseNCOToConcatenateFiles(string filein, string fileout)
{
// Prepare the process to run
ProcessStartInfo start = new ProcessStartInfo();
// Enter in the command line arguments, everything you would enter after the executable name itself
StringBuilder sb = new StringBuilder();
sb.Append(" -O --no_tmp_fl ");
sb.Append(fileout);
sb.Append(" ");
sb.Append(filein);
sb.Append(" -o ");
sb.Append("test.nc");
start.Arguments = sb.ToString();
// Enter the executable to run, including the complete path
start.FileName = @"nco\ncrcat.exe ";
// Do you want to show a console window?
start.WindowStyle = ProcessWindowStyle.Hidden;
start.CreateNoWindow = true;
// Run the external process & wait for it to finish
using (Process proc = Process.Start(start))
{
this.Cursor = Cursors.WaitCursor;
proc.WaitForExit();
// Retrieve the app's exit code
int exitCode = proc.ExitCode;
if (exitCode != 0)
{
string errmessage = "There occured an error.\n Please try again.";
MessageBox.Show(errmessage, "Alert");
}
else
{
#region Using ncrcat, have to use the following extra file operations.
//Sometimes, they are very dangerous. So it'd better backing up firstly.
File.Copy(fileout, fileout + ".backup.nc", true);
File.Copy("test.nc", fileout, true);
File.Delete("test.nc");
#endregion End of extra file operations.
string message = Path.GetFileName(filein) + " has been concatenated to " + Path.GetFileName(fileout) + " successfully!";
MessageBox.Show(message, "Info");
}
this.Cursor = Cursors.Default;
}//end of using
}
合并前,要用到MeteoInfoC中的nc函数查看是否已经合并过等等。
MeteoInfoC中的函数我就不说了,自己看文档吧
|
|