If you look in my code, there's a method SaveFile and a method SaveFileAs. You'd need to have those methods too before you can call them.

This is meant as a complete example. Of course you can use bits and pieces from it, but you'll need to figure out for yourself which bits you need to change/replace/remove/add, because you won't be able to simply take a chunk out of the code and expect it to work.