Hi All,
I write a class to handle the metro read/write just like the win32 api, but I found it can't read the buffer to the specified buffer directly, for example, I can use the win32 api ReadFile with the specified buffer. but in metro app, it should new
a Platform::Array for reading, after that, copy the data from the Platform::Array to the destination memory, this way is inefficient, does anyone have any ideals? thanks!
DataReader^ dataReader = ref new DataReader(readStream); // IRandomAccessStream^ readStream
create_task(dataReader->LoadAsync(static_cast<UINT32>(size))).then([this, dataReader](unsigned int numBytesLoaded)
{
Platform::Array<byte>^ fileContent = ref new Platform::Array<byte>(numBytesLoaded);
dataReader->ReadBytes(fileContent);
delete dataReader; // As a best practice, explicitly close the dataReader resource as soon as it is no longer needed
});