Does BackgroundFileTransfer reserve disk space before downloading the resource? RRS feed

  • Question

  • I wonder if I would have to manage this myself or does BFT reserves the amount of bytes on the target drive before starting the download? 

    If not, how could I myself reserve the space before starting the download? The WinRT file i/o APIs do not seem to have something like SetFilePointer(expectedSize, SEEK_SET)

    Monday, September 24, 2012 11:57 AM

All replies

  • May I ask why you need to do this or want to?  You can see how much space is left on any drive & if not enough is available such as usb drive, ask you to save it somewhere else...as for reserving the only way I know is create a file of that size with blank data, maybe just all 0's or something & save the file, overwrite the file when saving the data...

    Unless you expect saving to be a long operation & that they will continue to add data to said device & probably run low(main hard disk, likely they will have enough always, usb drive...limited but unless it's huge interaction with it will be minimal & they will likely not try to add data while the other transfer is still going...)

    If you tell me your goal I may be able to help but as for reserving space when saving to the main hard drive, usually people don't run out so easily & even then unless their very close to the limit, nothing they do while saving will take up that much space...

    Monday, September 24, 2012 2:23 PM
  • I need it in a drop box like scenario. I would not need to start downloading a 100MB file if there are only 20MB left in the apps local storage (maybe because of a quota set on the users folder). Also by reserving the space beforehand the user could take action to free up space and then let my app continue downloading.

    Its much like the file copy process to USB drives already behaves now, except it does not reserve the space on the target drive. But it does not allow you to copy a set of files if it already knows there is not enough space on the target.

    And yes, the file would have to filled up with random values when reserving the space. In good old Win32 all you do is SetFilePointer.

    If BFT does not support this, how does it notify my app about the fact that the target drive is full (or has hit a quota for the current user)?

    Monday, September 24, 2012 2:30 PM
  • I was not aware the apps local storage had a quota, I was aware that there was a quota for roaming storage, of not even very large at all...

    How are you able to see the quota limit for local storage???  As for any errors appearing saving, etc... it can know & even popup a message saying so because all that is coded into filepicker & filesaver & all that such stuff to check any such quotas, etc... before allowing it to save to those destination folders...if you are saving too much & hitting some type of quota though I would recommend saving outside of local storage, any videos, documents, music, etc... to be placed in those respective folders instead, and labeled in folders with your apps name to let them know why it's there.

    Anyways, I don't know anything like SetFilePointer equivalent either...but you can write a file of the same size using random data as a way to reserve space, but I think it's much easier just to allow a warning if you wouldn't be able to download the whole thing, rather than reserving, unless your thing downloads more than one thing at once, and need to take into account total size, which then I would say take into account total file size(s) when doing the math(such as taking into account the file sizes of the files being downloaded still) rather than allowing them to get most of the way done & not be able to finish.

    Monday, September 24, 2012 4:04 PM
  • I believe admins can set user storage quota. You cannot check that from WinRT though.

    Beside that I have to save inside the local storage as my data are not files that user should see in the normal file system.

    But I think you are right, I will first try to download everything and in case of an error just display this error and give the user the chance to resume the download (given that BackgroundFileTransfer supports that).

    Tuesday, September 25, 2012 9:01 AM