Hi Thomas,

You can write to a file by using the %File library class as follows:

        set tTempFile=##class(%FileCharacterStream).%New()
        set tTempFile.Filename=filename
        set tSC=tTempFile.CopyFrom(tStream)
        set returnValue=tTempFile.%Save()
 

You will be able to get the file name that was read in the service from the Ens.StreamContainer. It has a property called OriginalFilename that has the absolute filename saved. If the business service managed to pick up the type of file that it processed it will be populated in the Type property.