Hi,

refer to documentation of class %SerialStream, especially methods CopyFromAndSave and SaveStream

I'm writing a Cach� Objectscript routine that has to download a file using
FTP and write it to a disk. I've got the FTP side working, but when I close
the newly created file it disappears. How do I create a file using a
%FileBinaryStream and get it to hang around so I can open it again and read
it, or do I have to create and write the file in the old-fashioned way?

Here's my code:
 Set F=##CLASS(%Net.FtpSession).%New()
 If 'F.Connect(FTPSERV,FTPUSER,FTPPWD) D UPDSTAT^CXMLMJ("FTP Unable to
connect to "_FTPSERV) S RTN="" G DF90
 If 'F.SetDirectory(JRNPATH) S RTN="" D UPDSTAT^CXMLMJ("FTP Unable to set
directory to "_JRNPATH) G DF80
 ;
 Set stream=##class(%FileBinaryStream).%New("WNS")
 Set stream.Filename=RTN
 ;
 If 'F.Retrieve(FNAME,stream) D UPDSTAT^CXMLMJ("FTP Unable to retrieve file
"_FNAME_" to "_RTN) S RTN="" G DF80 ; Retrieve the file

d stream.SaveStream() ; should do the job s stream=""

Do stream.%Close()


Pavel



Reply via email to