Hi All,
You can move the given file from source to given directory through Linux C program as mentioned in the below example:
If we need to move the info.txt file from its location /data/working to /data/archive folder just call this below function.
If we need to move the info.txt file from its location /data/working to /data/archive folder just call this below function.
void MoveTheFileToDir(void)
{
char cMvFileToDirCmd[1024];
sprintf(cMvFileToDirCmd, "mv \/data\/working\/info.txt \/data\/archive");
system(cMvFileToDirCmd) ;
}
Assumptions: Both /data/working and /data/archive are in immediate after the root folder such as root folder/data/working. In Linux root folder can be referred by "/" character
If the /data/working is in another folder after the root let us say
root directory/device/data/working then file path need to be changed and the program changes as below.
void MoveTheFileToDir(void)
{
char cMvFileToDirCmd[1024];
sprintf(cMvFileToDirCmd, "mv \/device\/data\/working\/info.txt \/device\/data\/archive");
system(cMvFileToDirCmd) ;
}
No comments:
Post a Comment