PDA

Click to See Complete Forum and Search --> : how do i read the size of an exe???


NiGhTRiDeR_Si
Sep 5th, 2002, 02:56 PM
hey guys
i was just wondering how do i read the size of an exe when im copying a file.... my copy command that i made always stops at 215 b.....
thx guys

jim mcnamara
Sep 5th, 2002, 03:29 PM
Two comments - you are hitting an ASCII 26 character at position 215 in the image header. When you open a binary file and read it as text, when you hit CTRL-Z (26) the read returns EOF.

Open the file as binary., write to a binary-open file.

Or do it the easy way:

int retval = CopyFile("C:\\folder\\file1.exe","d:\\folder\\anotherfile.exe",0L);


include windows.h

jim mcnamara
Sep 5th, 2002, 03:32 PM
Oh. forgot.

stat the file to get it's size.


struct stat a;
if(stat("C:\\myfile.exe",&a) ){
perror("Cannot stat file");
exit(1);
}
printf("File size in bytes is %d\n",a.st_size);