1. 方法实现
using ESRI.ArcGIS.Geoprocessor;
using ESRI.ArcGIS.Geoprocessing;
using ESRI.ArcGIS.DataManagementTools;
using ESRI.ArcGIS.AnalysisTools;
public static bool CopyFeatureClass(string inputPaths, string outputPath)
{
Geoprocessor gp = null;
IGeoProcessorResult result = null;
try
{
Copy pCopy = new Copy(inputPaths, outputPath);
gp = new Geoprocessor();
gp.OverwriteOutput = true;
gp.TemporaryMapLayers = false;
result = (IGeoProcessorResult)gp.Execute(pCopy, null);
if (result != null)
return true;
else
return false;
}
catch
{
string str = ReturnMessages(gp);
return false;
}
finally
{
if (gp != null)
{
gp = null;
}
GC.Collect();
GC.WaitForFullGCComplete();
}
}
/// <summary>
/// 处理错误信息
/// </summary>
/// <param name="gp"></param>
/// <returns></returns>
private static string ReturnMessages(Geoprocessor gp)
{
string ms = "";
if (gp.MessageCount > 0)
{
for (int Count = 0; Count <= gp.MessageCount - 1; Count++)
{
ms += "$" + gp.GetMessage(Count) + "\n\n";
}
}
if (ms.Contains("Succeeded") || ms.Contains("成功"))
{
//MarkConfig(true);
return "";
}
return ms;
}
2. 使用方式
CopyFeatureClass(strpath + "\\" + GT_COMMONNOUN.NJQ + "_" + strMC + "_" + strDM, strpath + "\\" + GT_COMMONNOUN.hz_njq);
网友评论