FIle to Byte ARray

Posts 1–5 of 5 · Page 1 of 1
FIle to Byte ARray
Any On Can You Give me
File To Array Byte

Thankz
C#/VB:
Code:
File.ReadAllBytes(@"path_to_the_file");
C++:
Code:
FILE * file = fopen("path_to_the_file", "rb");
if(file)
{
     fseek(file, 0, SEEK_END);
     int size = ftell(file);
     rewind(file);
     BYTE * data = new BYTE[size+1];
     ZeroMemory(data, size+1);
     fread(data, 1, size, file);
     fclose(file);
     free(data); or return data;
}
Quote Originally Posted by UltraPGNoob View Post
C#/VB:
Code:
File.ReadAllBytes(@"path_to_the_file");
C++:
Code:
FILE * file = fopen("path_to_the_file", "rb");
if(file)
{
     fseek(file, 0, SEEK_END);
     int size = ftell(file);
     rewind(file);
     BYTE * data = new BYTE[size+1];
     ZeroMemory(data, size+1);
     fread(data, 1, size, file);
     fclose(file);
     free(data); or return data;
}
reading all bytes at once?? i dont recommend doing so, and it seems to not work probably, i usually read in small buffers like 1024 bytes.
It's just an example. But he could do it differently.
He didn't really point out how he wanted it to be done.
my request is .exe not the code

ex: filetoarraybyte.exe
Posts 1–5 of 5 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us