Exactly the same way you do from any other C++ code:
Input/output with files - C++ Tutorials[
^]
The only complication is access: services do not run under your user, so they generally will not have access to any of your files. To write a file, you will have to use a folder that has the appropriate write permissions for the service to be able to create and edit files.