I am trying to write a file to a directory that exists and is created by me in G:\\\\
i.e. not a system directory or in root drive
like this
I had a similar issue and stumbled across this thread looking for an answer to another issue I am having.
But you issue sounds similar to one I had a few weeks ago, and the issue was that SYSTEM needed to also have Full Control over the folder.
May or may not be the issue, but mentioned incase it solves your or someone else's similar issue to what I experienced.