/// <summary>
 /// adds a layer to the active view
 /// </summary>
 /// <param name="path">full path name</param>
 /// <returns>Ilayer</returns>
 public ILayer addLayer(string path)
 {
     IMap map = (IMap)acView;
     geoDatabaseUtility geoUtil = new geoDatabaseUtility();
     esriDatasetType dType = geoUtil.getDataType(path);
     ILayer lyr = null;
     switch(dType)
     {
         case esriDatasetType.esriDTFeatureClass:
             IFeatureLayer ftrLayer = new FeatureLayerClass();
             ftrLayer.FeatureClass = geoUtil.getFeatureClass(path);
             lyr = (ILayer)ftrLayer;
             lyr.Name = ftrLayer.FeatureClass.AliasName;
             map.AddLayer(lyr);
             break;
         case esriDatasetType.esriDTRasterBand:
         case esriDatasetType.esriDTRasterCatalog:
         case esriDatasetType.esriDTRasterDataset:
             IRasterLayer rasterLayer = new RasterLayerClass();
             rasterLayer.CreateFromDataset(geoUtil.getRasterDataset(path));
             rasterLayer.Name = rasterLayer.Name;
             map.AddLayer((ILayer)rasterLayer);
             break;
         case esriDatasetType.esriDTTable:
             ITable tbl = geoUtil.getTable(path);
             ITableCollection tableCollection = (ITableCollection)map;
             tableCollection.AddTable(tbl);
             break;
         default:
             break;
     }
     acView.Refresh();
     return lyr;
 }
        static void Main(string[] args)
        {
            //ESRI License Initializer generated code.
            m_AOLicenseInitializer.InitializeApplication(new esriLicenseProductCode[] { esriLicenseProductCode.esriLicenseProductCodeAdvanced}, new esriLicenseExtensionCode[] {});
            System.DateTime dt = System.DateTime.Now;

            System.DateTime dt2;
            TimeSpan ts;
            rasterUtil rsUtil = new rasterUtil();
            geoDatabaseUtility geoUtil = new geoDatabaseUtility();
            featureUtil ftrUtil = new featureUtil();
            string zones = @"C:\Users\jshogland\Documents\JOHN\Requests\TaceyFrescino\forFIESTA\test.gdb\utcobnd";
            string values = @"C:\Users\jshogland\Documents\JOHN\Requests\TaceyFrescino\forFIESTA\test.gdb\AdminBoundary";
            string[] flds = { "m_BAA_all_1" };
            IFeatureClass zonesFtr = geoUtil.getFeatureClass(zones);
            IFeatureClass valuesFtr = geoUtil.getFeatureClass(values);
            ftrUtil.weightFieldValuesByAreaLength(valuesFtr, flds, zonesFtr);

            //string ftpSite = @"ftp://rockyftp.cr.usgs.gov/vdelivery/Datasets/Staged/NAIP/mt_2013/";
            //List<string> fNames = getFileNames(ftpSite);
            //string outDir = @"E:\Helena\NAIP\Bulk Order 421750\NAIP JPG2000";
            //List<string> exNames = getExistingNames(outDir);
            //List<string> tiles = getTiles();
            //for (int i = 0; i < fNames.Count; i++)
            //{
            //    string fName = fNames[i];
            //    string lfn = fName.Substring(0, 7);
            //    if (tiles.Contains(lfn.ToLower()))
            //    {
            //        if (!exNames.Contains(fName))
            //        {
            //            Console.WriteLine("Total number of files = " + fNames.Count.ToString());
            //            Console.WriteLine("Downloading " + fName);
            //            bool gotFile = Download(ftpSite, outDir, fName);
            //            Console.WriteLine("Got File " + fName + " " + gotFile.ToString());
            //        }
            //    }
            //}
            dt2 = System.DateTime.Now;
            ts = dt2.Subtract(dt);
            Console.WriteLine("Total Seconds RawBlock= " + ts.TotalSeconds.ToString());

            m_AOLicenseInitializer.ShutdownApplication();
        }