blöde frage



  • kannst du mir mal ein beispiel geben für CopyFile???



  • Oder kann mir irgendwer zeigen wie ich CopyFile schreiben muss damit es funktioniert???
    Ich weiss nicht wie ich es schreiben soll ......



  • Und was verstehst du hieran nicht???
    **MSDN:

    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, // name of an existing file
      LPCTSTR lpNewFileName,      // name of new file
      BOOL bFailIfExists          // operation if file exists
    );
    

    Parameters
    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 File Name Conventions.

    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 File Name Conventions.

    Windows 95/98/Me: This string must not exceed MAX_PATH characters.

    bFailIfExists
    [in] Specifies how this operation is to proceed if a file of the same name as that specified by lpNewFileName already exists. If this parameter is TRUE and the new file 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.**



  • das es english ist.... 🙄



  • schreib ich als newfilename den pfad oder einfach nur einen neuen namen und als lpExistingFileName den wie die urdatei heisst???

    und wenn ich fragen will, wo das neue file hingesetzt werden soll wo setzt ich das hin???



  • Ich denke mal mit Pfadangabe. denn sonst wird wahrcheinlich die Current-Directory genommen.
    Einfach mal probieren. Das geht doch schneller als auf eine Antwort zu warten oder?



  • Hallo,

    hab das jetzt so gemacht :

    CopyFile("..\\matrix2x2.sml", "..\\matrixbla.sml", false);
    

    geht aber nicht, er kopiert einfach nicht.
    Jemand noch eine idee??
    Ich habe es übrigens schon mehr fach probiert, immer anders es geht trotzdem nicht.



  • Kann mir jemand helfen??

    CStdioFile out_file;	// deklaration output file
    
    	CFileDialog file_dlg = CopyFile("..\\matrix2x2.sml", "file_neu", true);
    
    	CFileDialog file_neu(false,_T("sml"), 0, OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST,_T("SML Files (*.sml) | *.sml | All Files (*.*) | *.* ||"), this);
    
    //	 CFileDialog file_dlg = CopyFile("..\\matrix2x2.sml", "file_neu", true);
    
    	// öffnen Dialog wo gespeichert werden soll, als txt 
    
    	if (file_dlg.DoModal()==IDOK)		// if input ok 
    	{
    
    		//CFileDialog file_dlg = CopyFile("..\\matrix2x2.sml", "file_neu", true);
    
    		CString m_file_name = file_dlg.GetPathName();
    
    		//ab hier wie es im textfile steht. 
    
    	if (out_file.Open(m_file_name, CFile::modeCreate | CFile::modeWrite))  
    		..
    
    ..
    ..
    

    Waru´m geht das nicht??
    Ich möchte eine kopie erstellen von matrix2x2 diese will ich dann weiter verwenden (die kopie) und eine eingabe darin speichern.
    Es geht aber nicht.
    Kann mir jemand noch helfen ????
    BITTE



  • Hallo !

    Wenn CopyFile(...) nicht funktioniert, findet er wahrscheinlich die zu kopierende Datei nicht.
    Entweder gibst du den genauen Pfad und den Dateinamen EINER VORHANDENEN Datei an, die kopiert werden soll, oder:

    Mal angenommen, du hast z.B. so eine Ordnerstruktur:
    C:\UebergeordneterOrdner\ProjektOrdner\Debug
    wobei:
    in Debug ist die EXE
    in ProjektOrdner sind die CPP und H
    in UebergeordneterOrdner ist sonstwas

    Bei
    CopyFile("matrix2x2.sml", "file_neu", true);
    sucht er matrix2x2.sml in ProjektOrdner

    Bei
    CopyFile("..\\matrix2x2.sml", "file_neu", true);
    sucht er matrix2x2.sml in UebergeordneterOrdner

    Durchsuche einfach mal deine Festplatte, ob er file_neu irgendwo anders (z.B. im Temp-Verzeichnis) angelegt hat.

    P.S.:
    nicht SOOO wichtig, aber der dritte Parameter: TRUE oder FALSE (statt true oder false)

    Tschüss



  • aber der rest im code war richtig???!!!!
    hab geschaut das file_new legt er nirgends hin.
    Hast du vielleicht eine idee wie ich das anders lösen kann. eine kopie von einer festen datei diese dann nehmen und unter anderen namen wo anders abspeichern + neuer inhalt der datei 😕 😕 😕



  • wie geht das mit diesem seektoend in der msdn hab ich geschaut, raff ich aber nicht ich brauch immer ein aussagekräftiges beispiel .... 🙄
    Bitte, helft mir


Anmelden zum Antworten