File_Rename(pOldName, pNewName), Byte
pOldName: The current name of the file to be renamed. The string must be a maximum of 12 characters, including the file extension (e.g., MyFile.txt).
pNewName: The new name for the file. It also must be a string with a maximum length of 12 characters, including the extension.
Return Byte:
• cErrOK: Success – the file was renamed successfully.
• cErrExists: The new file name already exists – you cannot rename a file to a name that is already in use by another file or directory.
• cErrNotFound: The old file name was not found – the file you're trying to rename doesn't exist.
• cErrRWError: A read/write error occurred – there was an issue while renaming the file, possibly due to a disk error or filesystem issue.
Rename a File
The File_Rename() command allows you to rename an existing file on the SD card. This operation modifies the file name in the filesystem while keeping the file content intact.
Example:
File_Rename("OldFile.txt", "NewFile.txt")
How it Works:
• This command checks if the old file exists and if the new name is available.
• If the old file exists and the new name is valid (i.e., not already taken), it will rename the file.
• The file content and the file's properties remain unchanged; only the name of the file is modified in the filesystem.
Notes:
• File Size and Content: The file’s content is unaffected by this operation. Only the file’s name in the filesystem is updated.
• File/Directory Name Conflict: If a file with the new name already exists, the operation will fail with cErrExists.
• Filesystem Integrity: The filesystem is updated with the new file name, so other operations that depend on the file name (like File_Open(), File_Append(), or File_OpenAt()) will now use the new name.
TftSetUp(0) 'Set screen TftResetScreen(BLACK) 'Reset screen TftSetSndFont(0,0) 'Set Font0 While File_Init() <> cErrOK : Wend 'Initialize SD Card TftPrintSndString("Sd Initialization OK",1,0,0,1,GREEN,BLACK,0) 'Confirm Initialize SD Card While File_Rename("pic.log","gif.txt") <> cErrOK : Wend 'Rename file pic.log to gif.txt TftPrintSndString("Rename pic.Log OK",1,0,2,1,GREEN,BLACK,0) 'Confirm rename file pic.Log To gif.txt While File_RenameDir("test","stop") <> cErrOK : Wend 'Rename folder test to stop TftPrintSndString("Rename test OK",1,0,3,1,GREEN,BLACK,0) 'Confirm rename folder test To Stop |
|
Created with the Personal Edition of HelpNDoc: Experience the Power and Ease of Use of HelpNDoc for CHM Help File Generation