Autor Beitrag
Chris2
Hält's aus hier
Beiträge: 1



BeitragVerfasst: Mi 28.08.02 18:19 
Habe Zwei Rechner im Netzwerk, bei denen jeweils die c-platte freigegeben ist.

\\PC01\c
\\PC02\c

und möchte jetzt, dass die Dateien von \\PC01\c\windows\fonts
ins verzeichnis \\PC02\c\windows\fonts kopiert werden,
damit beide Rechner die gleichen Schriftarten besitzen.

beim Kopieren soll das Programm jedoch bereits vorhandene Dateien im Zielordner übergehen, um dann gleich mit der nächsten Datei fortzufahren.

wie lautet der kopierbefehl?
DeCodeGuru
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1333
Erhaltene Danke: 1

Arch Linux
Eclipse
BeitragVerfasst: Do 29.08.02 08:31 
ich habe jetzt keine psdk oder delphihilfe vor mir, aber probier es mal mit CopyToFile (o.ä.) ich glaube, da kann man auch einstellen, dass schon existierende dateien überschrieben werden sollen.

_________________
Viele Grüße
Jakob
MathiasSimmack
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Do 29.08.02 10:26 
PSDK hat folgendes geschrieben:

ausblenden 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.
Klabautermann
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Veteran
Beiträge: 6366
Erhaltene Danke: 60

Windows 7, Ubuntu
Delphi 7 Prof.
BeitragVerfasst: Do 29.08.02 10:55 
Hallo,

du kannst bevor du CopyFile aufrufst die Existenz der Zieldatei mit FileExists überprüfen. Existiert sie Kopierst du sie eben nicht.

Gruß
Klabautermann