Page 1 of 1

CopyFile() on windows

Posted: Mon Mar 14, 2016 1:00 pm
by lazi
It is really hard to live on the wintel world :(

I want to copy a file to the temporary drawer (folder) because of other command line weirdness.

The CopyFile() has a destination drawer argumentum, but it do not handle %temp% style insanity.
The temp drawer is in the registry under HKCU/Environment/Temp, but contains %userprofile%. Recursive insanity. :((

To workaround I am trying to use the default temp path %USERPROFILE%\AppData\Local\Temp. (What if it is not there on some config?)

GetSystemInfo() can give me the user's AppData path, but it is not the same as %USERPROFILE%\Appdata. :evil:

So, CopyFile("source.txt",GetSystemInfo().appdata.."\\..\\Local\Temp") works with the default settings.

Anyone heard about the invention of 'T:' ? Bah...

Re: CopyFile() on windows

Posted: Mon Mar 14, 2016 9:22 pm
by airsoftsoftwair
Why not use GetTempFileName()?

Re: CopyFile() on windows

Posted: Tue Mar 15, 2016 6:05 pm
by lazi
What did you say? GetTempFileName()? :oops:
Ohh man, that problem was stolen several hours from my life.

But how on earth should I remember all of the functions, the guide is now at 2 and a half megabytes long? :P

Re: CopyFile() on windows

Posted: Tue Mar 15, 2016 10:30 pm
by airsoftsoftwair
It's a very old function actually... has been present since v3.0. That's like 8 years or so :)