CopyFile() on windows

Discuss any general programming issues here
Post Reply
User avatar
lazi
Posts: 625
Joined: Thu Feb 24, 2011 11:08 pm

CopyFile() on windows

Post 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...
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: CopyFile() on windows

Post by airsoftsoftwair »

Why not use GetTempFileName()?
User avatar
lazi
Posts: 625
Joined: Thu Feb 24, 2011 11:08 pm

Re: CopyFile() on windows

Post 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
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: CopyFile() on windows

Post by airsoftsoftwair »

It's a very old function actually... has been present since v3.0. That's like 8 years or so :)
Post Reply