How to use File::ReadAllBytes in visual c++?

936 views Asked by At

Visual Studio has a simple method "File::ReadAllBytes" that will read a file and return a byte array, but I don't know how to use it. I tried the following and they all don't work.

Byte arr[] = File::ReadAllBytes("file.txt");
Byte *arr = File::ReadAllBytes("file.txt");
unsigned char arr[] = File::ReadAllBytes("file.txt");
unsigned char *arr = File::ReadAllBytes("file.txt");

unsigned char *arr;
arr = File::ReadAllBytes("file.txt");
1

There are 1 answers

2
user253751 On

File::ReadAllBytes is a .NET function, so you cannot call it from C++.

You can call it from C++/CLI (Microsoft's .NET version of C++), but you have clarified that you are not using C++/CLI.