GPPointFileInfo\GPRecurseInputSubfolders.cs
Creating a non-trival custom GP tool - inputs, outputs, and responding to environment settings
GPPointFileInfo\GPRecurseInputSubfolders.cs
// Copyright 2008 ESRI
// 
// All rights reserved under the copyright laws of the United States
// and applicable international laws, treaties, and conventions.
// 
// You may freely redistribute and use this sample code, with or
// without modification, provided you include the original copyright
// notice and use restrictions.
// 
// See use restrictions at <your ArcGIS install location>/developerkit/userestrictions.txt.
// 

using ESRI.ArcGIS.Geoprocessing;
using ESRI.ArcGIS.Geodatabase;

namespace GPPointFileInfo
{
    public class GPRecurseInputSubfolders : GPPointFileInfo.IGPRecurseInputSubfolders
    {
        private static int _parameterIndex;

        private bool _recurseSubfolders;

        public GPRecurseInputSubfolders(IParameterValueArray parameterValueArray)
        {
            IGPValue gpValue = parameterValueArray.GetGPValue(_parameterIndex);

            _recurseSubfolders = GetRecurseSubfolders(gpValue);
        }

        public static IGPParameterEdit GetGPParameterEdit()
        {
            IGPParameterEdit gpParameterEdit = new GPParameterClass();

            IGPDataType gpDataType = new GPBooleanTypeClass();

            IGPBoolean gpBoolean = new GPBooleanClass();

            gpBoolean.Value = false;

            IGPValue gpValue = gpBoolean as IGPValue;

            gpParameterEdit.Name = "recurse_in_input_subfolders";
            gpParameterEdit.DisplayName = "Recurse Input Subfolders";
            gpParameterEdit.DataType = gpDataType;
            gpParameterEdit.Value = gpValue;
            gpParameterEdit.Direction = esriGPParameterDirection.esriGPParameterDirectionInput;
            gpParameterEdit.ParameterType = esriGPParameterType.esriGPParameterTypeOptional;

            return gpParameterEdit;
        }

        public static void SetGPParameterIndex(int index)
        {
            _parameterIndex = index;
        }

        public bool RecurseSubfolders
        {
            get
            {
                return _recurseSubfolders;
            }
        }

        private bool GetRecurseSubfolders(IGPValue gpValue)
        {
            bool recurseSubfolders;

            IGPBoolean gpBoolean = gpValue as IGPBoolean;

            recurseSubfolders = gpBoolean.Value;

            return recurseSubfolders;
        }
    }
}