As markkuk say, the process is exactly the same than when you want to write to a local file. Being that said, you should try to write the file in a local folder and then change the path to one remote one (\\server\shared folder\xxx\yyy\zzz.aaa) of course it will fail if the remote path is not available so keep this in mind and test it... it would surely be a problem if your application fails suddenly because the remote path does not exists.
Just in case... and in order to know how to
write files[
^]...
Hope this helps.