Veröffentlicht 24. Februar 200223 j Hi, wie kann ich mit C/C++ eine Datei kopieren, löschen und verschieben? Ich habe es schon mit der Funktion System() probiert, mit der es auch funktioniert. Aber leider erscheint dann das command window, welches nicht eingeblendet werden soll. TIA
24. Februar 200223 j verschieben: BOOL MoveFile( LPCTSTR lpExistingFileName, // pointer to the name of the existing file LPCTSTR lpNewFileName // pointer to the new name for the file ); und mit Umbenennen: MoveFileEx The MoveFileEx function renames an existing file or directory. BOOL MoveFileEx( LPCTSTR lpExistingFileName, // pointer to the name of the existing file LPCTSTR lpNewFileName, // pointer to the new name for the file DWORD dwFlags // flag that specifies how to move file ); löschen: DeleteFile The DeleteFile function deletes an existing file. BOOL DeleteFile( LPCTSTR lpFileName // pointer to name of file to delete ); kopieren: CopyFile The CopyFile function copies an existing file to a new file. BOOL CopyFile( LPCTSTR lpExistingFileName, // pointer to name of an existing file LPCTSTR lpNewFileName, // pointer to filename to copy to BOOL bFailIfExists // flag for operation if file exists ); Ansonsten nochmal die komplette Liste: File Functions The following functions are used with files. AreFileApisANSI CancelIo CopyFile CopyFileEx CopyProgressRoutine CreateDirectory CreateDirectoryEx CreateFile CreateIoCompletionPort DefineDosDevice DeleteFile FileIOCompletionRoutine FindClose FindCloseChangeNotification FindFirstChangeNotification FindFirstFile FindFirstFileEx FindNextChangeNotification FindNextFile FlushFileBuffers GetBinaryType GetCurrentDirectory GetDiskFreeSpace GetDiskFreeSpaceEx GetDriveType GetFileAttributes GetFileAttributesEx GetFileInformationByHandle GetFileSize GetFileType GetFullPathName GetLogicalDrives GetLogicalDriveStrings GetLongPathName GetQueuedCompletionStatus GetShortPathName GetTempFileName GetTempPath LockFile LockFileEx MoveFile MoveFileEx PostQueuedCompletionStatus QueryDosDevice ReadDirectoryChangesW ReadFile ReadFileEx ReadFileScatter ReadFileVlm RemoveDirectory SearchPath SetCurrentDirectory SetEndOfFile SetFileApisToANSI SetFileApisToOEM SetFileAttributes SetFilePointer SetVolumeLabel UnlockFile UnlockFileEx WriteFile WriteFileEx WriteFileGather WriteFileVlm Obsolete Functions _hread _hwrite _lclose _lcreat _llseek _lopen _lread _lwrite OpenFile SetHandleCount
24. Februar 200223 j Hi, Danke für deine Antwort. Aber irgendwie komme ich damit nicht so richtig zu recht. Kannst du mir vielleicht etwas weiterhelfen? Ein Beispiel oder so? TIA
26. Februar 200223 j CopyFile ("c:\\windows\\java.exe","c:\\temp",true); MoveFile ("c:\\temp\\java.exe","c:\\"); MoveFileEx ("c:\\java.exe","c:\\tmp\\test.ini",MOVEFILE_REPLACE_EXISTING); DeleteFile ("c:\\tmp\\test.ini");
26. Februar 200223 j Danke, habe er aber bereits schon rausgefunden. Hatte einen kleinen "Denkfehler".
26. März 200223 j CopyFile ("c:\\windows\\java.exe","c:\\temp",true); Wofür ist der Parameter true. Hab da jetzt mal false eingegeben und es funzt trotzdem! Er kopiert trotzdem alles! Patrick
26. März 200223 j Alles hier nachzulesen: CopyFile The CopyFile function copies an existing file to a new file. BOOL CopyFile( LPCTSTR lpExistingFileName, // pointer to name of an existing file LPCTSTR lpNewFileName, // pointer to filename to copy to BOOL bFailIfExists // flag for operation if file exists ); Parameters lpExistingFileName Pointer to a null-terminated string that specifies the name of an existing file. lpNewFileName Pointer to a null-terminated string that specifies the name of the new file. bFailIfExists 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.
26. März 200223 j Jo danke! Hab ich oben nicht gesehen! :eek: Danke für die schnelle Antwort. Patrick
Archiv
Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.