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

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
  • 55
  • 1
  • 1

Answers

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