Independentsoft
Professional software libraries for developers
Home
Purchase
Support
Company
Contact
Graph C++
>
Tutorial
> Download file
Download file as byte array.
C++ example
#include
#include
#include
#include
#include "independentsoft/graph/graph_client.hpp" #include "independentsoft/graph/graph_exception.hpp" #include "independentsoft/graph/files/drive_id.hpp" using namespace independentsoft::graph; using namespace independentsoft::graph::files; int main() { try { GraphClient client; client.client_id = "63333333-209e-454e-b7bd-55a4d201270f"; client.tenant = "independentsoft.onmicrosoft.com"; client.client_secret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; std::vector
bytes = sync_wait(client.get_drive_item_as_byte_array("/Folder1/Test.pdf", DriveId("b!T7ZW_FMzJ02x_G6HteZHZ"))); std::ofstream fileStream("e:\\Test-download.pdf", std::ios::out | std::ios::binary); fileStream.write(reinterpret_cast
(bytes.data()), static_cast
(bytes.size())); } catch (const GraphException& ex) { std::cout << "Error: " << ex.code << std::endl; std::cout << "Message: " << ex.message << std::endl; } return 0; }
Need help? Ask our developers:
Name*
Email*
Message*