Search code examples
c++-cli

Binary open file in c++/cli or c#


I have problem with Binary open file in c++/cli. How to open the whole file and save the contest of the file to the array ^.


Solution

  • A typical method for reading the contest [sic] of a Binarny [sic] file is to:
    1. Determine the length of the file.
    2. Allocate dynamic memory for the file.
    3. Block read the file, in binary mode, into memory.

    Some operating systems may have a memory map capability. This allows a file to be treated as an array. The OS is in charge of reading the file into memory. It may read the entire file, or it may read pages as necessary (on demand).

    See std::ifstream::read, std::ifstream::seekg and std::ifstream::tellg.