locked
fastest way to read files data RRS feed

  • Question

  • Hi! I try to write an app that read files from libraries, not app folder. I need file content presented as bytes.

    Now I use method from app examples: get StorageFile^ file, stream = file->openAsync, then read data with DataReader.

    This method reads file data with speed same as foobar2000 file read + decoding, so i try find a way make my file reading faster.

    1) Is it gives me something, if i create DataReader from IInputStream instead of IrandomAccessStream?

    2) This presentation says that better use IBuffer instead of DataReader. Is it? Also, cant find how create IBuffer from StorageFile.

    In addition need to say, i dont need whole file loading into memory.

    Can anybody consult me how make fastest file reading function?

    Wednesday, April 1, 2015 7:39 PM

All replies


  • You can just try the two method and compare the time to see which one is faster.
    Thursday, April 2, 2015 10:58 AM
  • So, as i find, reading file with FileIO::ReadBufferAsync loads whole file into memory. I dont need this - input file may have size <2gb. I need to read from small amounts of data (from 4 bytes) to mid (max is 1mb). As i understand, weak place of reading from IRandomAccessStream - async operation LoadAsync.

    Now my file reading scheme is: open StorageFile -> Create IRandomAccessStream from it -> Create DataReader from stream -> read parts until finish - return parts as Platform::Array^ -> release DataReader -> delete stream.

    Also i figured that if shelling this operations class is WinRT class (^) - it works faster than standart c++ class compiled as Release config with SSE2 instructions.

    1) Is there other way to load part of file into memory?

    2) Or could anybody give any advice how make reading file with IRandomAccessStream faster? 


    • Edited by Romka2411 Thursday, April 2, 2015 6:17 PM
    Thursday, April 2, 2015 6:00 PM