Dj_Fx8
asked on
Move a File
Hi
I am using ::MoveFile(sFrom, sTo) to move and re-name a file, which works ok but my problem is when the file is moved its Date Created is changed to the time it's moved. How can I move the file and keep the orginal creation date
I am using ::MoveFile(sFrom, sTo) to move and re-name a file, which works ok but my problem is when the file is moved its Date Created is changed to the time it's moved. How can I move the file and keep the orginal creation date
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Dj_Fx8,
yepp, CopyFile() modifies the date the same way MoveFile did, sorry.
AlexFM's comment sounds good (will try it now too :) )
leflon
yepp, CopyFile() modifies the date the same way MoveFile did, sorry.
AlexFM's comment sounds good (will try it now too :) )
leflon
ASKER
Ok whats wrong with this, for every file it says Cannot move file: Cannot read from the source file or disk. but the files are there ok ???
SHFILEOPSTRUCT lpFileOp;
lpFileOp.hwnd = pParent;
lpFileOp.wFunc = FO_MOVE;
lpFileOp.pFrom = sFrom;
lpFileOp.pTo = sTo;
lpFileOp.fFlags = FOF_RENAMEONCOLLISION | FOF_SILENT;
lpFileOp.fAnyOperationsAbo rted = FALSE;
lpFileOp.hNameMappings = NULL;
lpFileOp.lpszProgressTitle = NULL;
if (!SHFileOperation(&lpFileO p))
return TRUE;
SHFILEOPSTRUCT lpFileOp;
lpFileOp.hwnd = pParent;
lpFileOp.wFunc = FO_MOVE;
lpFileOp.pFrom = sFrom;
lpFileOp.pTo = sTo;
lpFileOp.fFlags = FOF_RENAMEONCOLLISION | FOF_SILENT;
lpFileOp.fAnyOperationsAbo
lpFileOp.hNameMappings = NULL;
lpFileOp.lpszProgressTitle
if (!SHFileOperation(&lpFileO
return TRUE;
lpFileOp.pFrom = sFrom;
pFrom
Address of a buffer to specify one or more source file names. Although this member is declared as a null-terminated string, it is used as a buffer to hold multiple file names. Each file name must be terminated by a single NULL character. An additional NULL character must be appended to the end of the final name to indicate the end of pFrom.
pFrom
Address of a buffer to specify one or more source file names. Although this member is declared as a null-terminated string, it is used as a buffer to hold multiple file names. Each file name must be terminated by a single NULL character. An additional NULL character must be appended to the end of the final name to indicate the end of pFrom.
ASKER
So what your saying is I have to add NULL on to the end of sFrom, as sTo can also contain a list of files do I need to add a NULL to it as well. One other small point, how do I add NULL onto the end of a string?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Well thats it working fine now, thanks guys for your help, I'll split the points, just as a closing comment I notice using SHFileOperation is considerably slower than ::MoveFile
i'm not sure about a change in creation date (will check this), but maybe you are better of with the duo of
CopyFile(org,new)
and
DeleteFile(org)
leflon