Lu Lu

Lu Lu

  • NA
  • 1
  • 1.3k

Store a custom property syncing with a Server

Oct 17 2013 9:54 AM
In my windows store app i sync with a Server and save files in this way:
StorageFile file = await ApplicationData.Current.LocalFolder.CreateFileAsync(fileName),
CreationCollisionOption.GenerateUniqueName);
var downloader = new BackgroundDownloader();
DownloadOperation download = downloader.CreateDownload(uri, file);

Now i want to add a metadata to the file such as the modificationDate of the file on the Server.
How can i store this information in order to retrieve the value if i close and re-open the app? Maybe the perfect solution is to extend the StorageFile class but it is sealed
A possible solution is to add the metadata in the field Comment of a file:
List<KeyValuePair<string, object>> extraProperties = new List<KeyValuePair<string, object>>();
extraProperties.Add(new KeyValuePair<string, object>("System.Comment", modificationDate));
await file.Properties.SavePropertiesAsync(extraProperties);

But this returns me an error: "Error HRESULT E_FAIL has been returned from a call to a COM component"....