I'm trying to use file output parameter in arcobjects geoprocessing tool which will be used as rest service on ArcGis server 10.1

IGPParameterEdit3 outParam = new GPParameterClass();
outParam.DataType = (IGPDataType)new DEFileTypeClass();
outParam.Value = (IGPValue)new DEFileClass();
outParam.Direction = esriGPParameterDirection.esriGPParameterDirectionOutput;
outParam.ParameterType = esriGPParameterType.esriGPParameterTypeDerived;
outParam.DisplayName = "ResultFile";
outParam.Name = "outResultFile";

What i do know is how to access file if that is input parameter:

IGPParameter inFileParam = (IGPParameter)paramvalues.Element[inFileParamID];
IDEFile deFile = inFileParam.Value as IDEFile;
IDataElement dataElement = deFile as IDataElement;
string filePath = dataElement.CatalogPath;

But what I'm trying to figure out is how to set output file. At the moment some things i have tried is:

IGPParameter outFileParam = (IGPParameter)paramvalues.Element[outFileParamID];
IDEFile deFile = outFileParam.Value as IDEFile;
IPersistStream pStream = deFile as IPersistStream;

ESRI.ArcGIS.esriSystem.FileStream fileStream = new ESRI.ArcGIS.esriSystem.FileStream();
IStream iStream = fileStream as IStream;

But last line throws COMException "Error HRESULT E_FAIL has been returned from a call to a COM component."

| improve this question | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.