Copying a file and reading size I get always zero.

I need to copy a file (srcFile) to a new ubication (destFile). Then I calculate the size of the copy file using stat. The problem is that I always get a cero size value although the file has not cero size in the hard disk.

The source code that does this is :

PROGRAM 1:

char srcFile[MAX_FILE_SIZE];
char destFile[MAX_FILE_SIZE];
int fileDest = 0;

strcpy(srcFile, "/dir1/file1.bin");
strcpy(destFile, "/dir2/newfile1.bin");

int rf = 255;

if (rf = rename(srcFile, destFile))
{
// Process error
}

struct stat dest_info;
int sr = stat(destFile, &dest_info);

printf("New file size is %d", dest_info.st_size);


Please, can you help me to solve this issue? Thanks in advance.

What's the value of sr?

You aer renaming a file, not copying it.
Topic archived. No new replies allowed.