getting an error: Method does not exist when trying to create a file

ObjectScript, Caché

I am trying to create a file from within a zen page but it keeps giving me a method does not exist error

in my page, i am taking the values and writing them to a file, when I do this :

 set filename= ##class(%Library.File).New("E:\test\file.txt") it gives me an error

Would appreciate some guidance on this.

  • 0
  • 0
  • 162
  • 1
  • 1


It's better to use file streams.

Set stream = ##class(%Stream.FileCharacter).%New()
Set sc = stream.LinkToFile("E:\test\file.txt")
Do stream.Write("Some Text")
Set sc = stream.%Save()

Thank you so much Eduard, this solved my issue.  Thank you for the advice, and the solution, really appreciate it