GPPointFileInfo\ESScratchWorkspace.cs
Creating a non-trival custom GP tool - inputs, outputs, and responding to environment settings
GPPointFileInfo\ESScratchWorkspace.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 ESScratchWorkspace : GPPointFileInfo.IESScratchWorkspace
    {
        private const string _EnvironmentName = "scratchWorkspace";
        private string _path;

        public ESScratchWorkspace(IGPEnvironmentManager gpEnvironmentManager)
        {
            IGPValue gpValue = gpEnvironmentManager.GetGPValue(_EnvironmentName);

            _path = GetPath(gpValue);
        }

        public string Path
        {
            get
            {
                return _path;
            }
        }

        private string GetPath(IGPValue gpValue)
        {
            string path;

            IDEWorkspace deWorkspace = gpValue as IDEWorkspace;

            IDataElement dataElement = deWorkspace as IDataElement;

            path = dataElement.CatalogPath;

            return path;
        }
    }
}