API to check OneDrive file status
-
26-12-2019 - |
Question
Is there an API in Windows 8.1 to check the status of a OneDrive file? I would like to know whether the file has been replicated to the local disk or it is just a dummy representation of a file in the cloud that doesn't take up local disk space
Solution
This information can be retrieved by calling StorageFile.Properties.RetrievePropertiesAsync() (http://msdn.microsoft.com/en-us/library/windows/apps/hh770652.aspx)
method and passing it "System.OfflineAvailability" (http://msdn.microsoft.com/en-us/library/windows/desktop/bb787532(v=vs.85).aspx)
in the list of properties to be retrieved.
Function will return a dictionary that will contain one of the 3 possible values: 0 - not available offline 1 - available offline 2 - not applicatble (not a SkyDrive/OneDrive file)
OTHER TIPS
You can use the StorageFile.IsAvailable property. See the following quickstart article: http://msdn.microsoft.com/en-us/library/windows/apps/xaml/dn467360.aspx
EDIT: in fact, as @Ghostrider mentions in the comment, this answer is incorrect. @Ghostrider has found the correct solution