Monday, June 15, 2009

Custom GP Task Parameter in C#

I'm current writing a custom GP tool that maps out all the input parameters for a given mxd file, and I have been having trouble with the input parameter of type file. After much searching, I realized that the input parameter needs to be of type DEFileTypeClass. This will allow a user to select any file type. So in my case, a user can select the .mxd file.

Here is a snippet on how to create that input:
param = new GPParameterClass();
param.DataType = new DEFileTypeClass();
param.Name = "MXD_FILE";
param.Value = new DEFileTypeClass().CreateValue( "" );
param.DisplayName = "MXD_FILE";
param.Direction = esriGPParameterDirection.esriGPParameterDirectionInput;
param.ParameterType = esriGPParameterType.esriGPParameterTypeRequired;
param.Enabled = true;