FileCopy



  • Gibt es vll auch in C eine FileCopy funktion??



  • In C werden nur sehr wenige OS-spezifische Funktionen direkt im Standard angeboten.

    In C wird das Konzept verfolgt, dass diese dann von den OS-Programmieren in APIs zur Verfügung gestellt werden.

    Wenn du uns verrätst für welches OS du programmierst können wir dir helfen 🙂

    MfG SideWinder



  • Auf dem Betriebssystem Windows XP



  • Im Falle von Windows immer die MSDN begutachten!

    Auszug aus der MSDN schrieb:

    CopyFile

    The CopyFile function copies an existing file to a new file.

    The CopyFileEx function provides two additional capabilities. CopyFileEx can call a specified callback function each time a portion of the copy operation is completed, and CopyFileEx can be canceled during the copy operation.

    BOOL CopyFile(
    LPCTSTR lpExistingFileName,
    LPCTSTR lpNewFileName,
    BOOL bFailIfExists
    );

    Parameters
    lpExistingFileName
    [in] Pointer to a null-terminated string that specifies the name of an existing file.
    In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\?\" to the path. For more information, see Naming a File.

    Windows Me/98/95: This string must not exceed MAX_PATH characters.
    lpNewFileName
    [in] Pointer to a null-terminated string that specifies the name of the new file.
    In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\?\" to the path. For more information, see Naming a File.

    Windows Me/98/95: 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.
    Return Values
    If the function succeeds, the return value is nonzero.

    If the function fails, the return value is zero. To get extended error information, call GetLastError.

    MfG SideWinder



  • -.-
    Kapier des leida net ganz so.
    Kannste mir vll. en Beispiel zeigen??
    z.B von C:\Verwaltung zu C:\Programmen\Verwaltung



  • steht ja alles schon schön von sidewinder da

    if(!CopyFile("C:\vonhier.txt", "C:\nachhier.txt", true))
    {
       printf("Fehler!\n");
       return -1;
    }
    

    du gibst als ersten parameter die zu kopierende datei an. dann als 2ten parameter das zielverzeichnis und neuer dateiname. der dritte parameter gibt an, ob die datei auch kopiert werden soll, wenn bereits eine datei mit diesem namen bestehnt.

    grs Grave



  • Dieser Thread wurde von Moderator/in rüdiger aus dem Forum Rund um die Programmierung in das Forum WinAPI verschoben.

    Im Zweifelsfall bitte auch folgende Hinweise beachten:
    C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?

    Dieses Posting wurde automatisch erzeugt.



  • Hmm man kanne echt alles unperfekt machen ^^

    if(CopyFile("C:\\Verwaltung\\Test.txt", "C:\\Programmen\\Verwaltung\\Test.txt", TRUE) == FALSE)
    {
       printf("Fehler!\n");
       return 1;
    }
    

Anmelden zum Antworten