First of all, you're calling class methods, so you don't need a file object. Instead of:

s file=##class(%File).%New()
d file.CopyFile(File,ArchivePath)
d file.Delete(File)

It's enough to write:

do ##class(%File).CopyFile(File,ArchivePath)
do ##class(%File).Delete(File)

Other things to consider:

  • You have file and File variables. That makes understanding what's going on more difficult than it should be.
  • Using full command names (set instead of s, do instead of d, etc.)

But, %File class has a method specifically for moving, so it's better to call it:

set Success = ##class(%File).Rename(File, ArchivePath, .RetCode)
write:(Success=$$$NO) "Rename failed with code: " _ RetCode

Well, in this case you definitely don't need to read from stream at all. You can save the stream in the database (or file using %Stream.FileCharacter)) and send it to the client later:

set stream = ##class(%Stream.GlobalCharacter).%New()
set sc = stream.CopyFromAndSave(%request.Content)
set oid = stream.%Oid()
kill (oid)
set stream = ##class(%Stream.GlobalCharacter).%Open(oid)
do stream.OutputToDevice()

Streams can be class properties too.

catch-scope is not seems to be reached

Have you enabled logging?

Error occurs on saving incorrect data and not on setting the data. Saving also does not throw an exception, only returns an error status.

Also you need to quit something:

#dim sc As %Status = $$$OK

try
{
  set myClass= ##class(SomeClass).%New()
  myClass.Date =  Sourcedata.Date  //Sourcedata send us wrong format to that datefield.
  set sc = myClass.%Save() // Error occurs on save.
} catch ex {
  set sc = ex.AsStatus()
  set errMsg = "Error in this method "  _ $System.Status.GetOneStatusText(sc)
  $$$LOGERROR(errMsg)
}
quit sc

On a side note, you're using 3 different naming conventions for variables in your snippet:

  • tHungarianNotation
  • CapitalCase
  • lowercase

It would probably be better to decide on one notation.