locked
Finding the size of a file stored in the app isolatedStorage. RRS feed

  • Question

  • Is there an easy way to find the size of a file stored in my app isolatedStorage?
    Basically I have different files stored in the app isolatedStorage (pictures, txt, video …) and I would like to be able to find each file size, any help in this regards will be highly appreciated.

    Thank you all in advance.
    Monday, February 13, 2012 3:19 AM

Answers

  • Length provides the number of characters, not the file size, any other ideas …
    Thank you
    Read the documentation again:
    Length returns the number of bytes in the file and not a character count.
    Tuesday, February 14, 2012 4:57 AM
  • Length provides the number of characters, not the file size, any other ideas …
    Thank you


    wrong it is size in bytes. however it does not give you size occupied in file system just the file size in bytes. FYI, there is no other method.

    Property Value

    Type: System.Int64
    The length of the IsolatedStorageFileStream object in bytes.

    Length represents the number of bytes currently in the file. It is not affected by isolated storage quota.

    Silverlight

    Supported in: 5, 4, 3

    Silverlight for Windows Phone

    Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

    XNA Framework

    Supported in: Xbox 360, Windows Phone OS 7.0
    Tuesday, February 14, 2012 6:05 AM
  • You may be able to look at the FileInfo.Length for the file while it is open.  I don't know if it reports the size while the FileSink is writing, but I think it grabs the data from the filesystem metadata, not by opening the file. 

    Or, rather than checking the opened file, check the filesystem.  Before recording, check AvailableFreeSpace.  Then on a timer while recording, check it again and again.  The movie recording size is the difference between the start and the subsequent samples - but also includes other file activities from other apps and the OS too. 
    Tuesday, February 14, 2012 10:33 PM

All replies

  • Currently, you have to open each file and look that the Lenght property.
    Monday, February 13, 2012 5:11 AM
  • Length provides the number of characters, not the file size, any other ideas …
    Thank you
    Tuesday, February 14, 2012 3:16 AM
  • Length provides the number of characters, not the file size, any other ideas …
    Thank you
    Read the documentation again:
    Length returns the number of bytes in the file and not a character count.
    Tuesday, February 14, 2012 4:57 AM
  • Length provides the number of characters, not the file size, any other ideas …
    Thank you


    wrong it is size in bytes. however it does not give you size occupied in file system just the file size in bytes. FYI, there is no other method.

    Property Value

    Type: System.Int64
    The length of the IsolatedStorageFileStream object in bytes.

    Length represents the number of bytes currently in the file. It is not affected by isolated storage quota.

    Silverlight

    Supported in: 5, 4, 3

    Silverlight for Windows Phone

    Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

    XNA Framework

    Supported in: Xbox 360, Windows Phone OS 7.0
    Tuesday, February 14, 2012 6:05 AM
  • Thank you for your reply, actually you were right, length will provide the size in bytes, I’m wondering why Microsoft chose “Length” instead of “Size” for example …

    Anyway one more question please:
    I’m trying to get a live size of a video while it is being recorded, therefore I have tried the code below, which is working fine, it can record the video then saves it correctly, but I was trying to find a way to provide the file size while it is being recorded …  any help in this regard?  Thank you all
    ------------------------------------------------------------------------------------------
    Private captureSource As CaptureSource
    Private fileSink As FileSink
    fileSink.CaptureSource = captureSource
    Dim FilePath1 As String = Path.Combine("General", VideoFileName)
    fileSink.IsolatedStorageFileName = FilePath1
    -------------------------------------------------------------------------------------------
    Thank you
    Tuesday, February 14, 2012 6:44 PM
  • I haven't given video recording a go so i might be wrong. to get the size you need to open the file and unfortunately that will most likely fail as file is already open.
    Tuesday, February 14, 2012 7:12 PM
  • Invoke IT Limited, you are right, actually I have tried that and it showed an error, which in short complains about the file being missing (because it has not been saved yet), I'm still trying to get this issue resolved but if anybody have any idea please share it with us.

    Thank you all
    Tuesday, February 14, 2012 9:28 PM
  • You may be able to look at the FileInfo.Length for the file while it is open.  I don't know if it reports the size while the FileSink is writing, but I think it grabs the data from the filesystem metadata, not by opening the file. 

    Or, rather than checking the opened file, check the filesystem.  Before recording, check AvailableFreeSpace.  Then on a timer while recording, check it again and again.  The movie recording size is the difference between the start and the subsequent samples - but also includes other file activities from other apps and the OS too. 
    Tuesday, February 14, 2012 10:33 PM
  • Fundamental Software Solutions Inc,

    checking AvailableFreeSpace ... idea has worked ... it gave a very close results to what i was expecting and i have checked it in tow phones ... smart thinking ... thank you
    Wednesday, February 15, 2012 11:07 PM