You can do it this way
Code: Select all
f$ = GetTemporaryDirectory() + "testfile.txt"
f = CreateFile(#PB_Any, f$)
This will fail on my computer:
Code: Select all
f = CreateFile(#PB_Any, "testfile.txt")
To make it work I have to modify it, or save it to a directory with the right permissions since in this case the current directory will be set by PB to the source directory and your CreateFile() which relies on the current directory will work.
But when I'm testing code from the forum, I just copy/paste/run it without saving it if I can avoid it.
Also your file may overwrite a file already there with the same name, and again this problem is mitigated if you use the temp dir.