PSDK hat folgendes geschrieben: |
Quelltext 1: 2: 3: 4: 5:
| BOOL CopyFile( LPCTSTR lpExistingFileName, // name of an existing file LPCTSTR lpNewFileName, // name of new file BOOL bFailIfExists // operation if file exists ); |
lpExistingFileName
[in] Pointer to a null-terminated string that specifies the name of an existing file.
Windows NT/2000/XP: In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to nearly 32,000 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. For more information, see Naming a File.
Windows 95/98/Me: This string must not exceed MAX_PATH characters.
lpNewFileName
[in] Pointer to a null-terminated string that specifies the name of the new file.
Windows NT/2000/XP: In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to nearly 32,000 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. For more information, see Naming a File.
Windows 95/98/Me: This string must not exceed MAX_PATH characters.
bFailIfExists
[in] If this parameter is TRUE and the new file specified by lpNewFileName already exists, the function fails. If this parameter is FALSE and the new file already exists, the function overwrites the existing file and succeeds. |
Aber wenn ich mir das so ansehe, dann will Chris2 ja nicht, dass vorhandene Dateien überschrieben werden. Und diese Funktion tut das entweder, oder sie bricht ab!
Das einzige, was mir jetzt noch einfällt, wäre
SHFileOperation, wobei man für die "SHFILEOPENSTRUCT"-Variable folgendes zusätzliche Flag benutzt:
PSDK hat folgendes geschrieben: |
FOF_RENAMEONCOLLISION
Give the file being operated on a new name in a move, copy, or rename operation if a file with the target name already exists. |
Damit wird zumindest ein Abbruch verhindert. Nachteil: die schon vorhandene Datei wird mit einem neuen Namen trotzdem kopiert.
Ansonsten bleibt wohl nur der Weg über
FindFirst/
FindNext/
FindClose, bei dem man jede Datei heraussucht, prüft, ob sie schon vorhanden ist, und ggf. kopiert.