首页 > Windows开发 > 详细

C# ArcEngine中打印出GP调用出错时的错误

时间:2015-08-10 17:59:18      阅读:545      评论:0      收藏:0      [点我收藏+]
public static bool Sample(List<string> inRasters,
            string locationData, string outTable,string resamplingType,string outExcel)
        {
            Geoprocessor gp = new Geoprocessor();
            gp.OverwriteOutput = true;

            string istr = inRasters[0];
            for (int j = 1; j < inRasters.Count(); j++)
            {
                istr += ";" + inRasters[j];
            }
            ESRI.ArcGIS.SpatialAnalystTools.Sample sam = new ESRI.ArcGIS.SpatialAnalystTools.Sample();
            sam.in_rasters = istr;//inRasters;
            sam.in_location_data = locationData;
            sam.out_table = outTable;
            sam.resampling_type = resamplingType;

            try
            {
                gp.Execute(sam, null);
            }
            catch (COMException e)
            {
                string str = "";
                for (int i = 0; i < gp.MessageCount; i++)
                {
                    str += gp.GetMessage(i);

                }
                MessageBox.Show(str);
                return false;
            }

            if (!ExcelUtil.CreateExcelByItable(outTable,outExcel))
            {
                MessageBox.Show("生成Excel表格失败!");
                return false;
            }
           
            return true;
        }

C# ArcEngine中打印出GP调用出错时的错误

原文:http://www.cnblogs.com/tsintian/p/4718511.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!