February, 2008

  • Eric Gunnerson's Compendium

    Uploading a file to HealthVault


    I came across a question asking how to upload a file to HealthVault, and decided to write a quick example.

    Files, like everything else in HealthVault, are stored in XML, and in fact, the File class is really a pretty thin wrapper over the underlying type. The File type stores the name of the file, the size, and the type of the content in the file.  The contents of the file is then stored in the "OtherData" member as a base-64 encoded string.

    Here's some code:

    FileInfo fileInfo = new FileInfo(@"C:\Documents and Settings\ericgu\My Documents\My Pictures\lame.jpg");
    using (FileStream stream = System.IO.File.OpenRead(fileInfo.FullName))
    BinaryReader reader = new BinaryReader(stream);
        byte[] fileContents = reader.ReadBytes((int) fileInfo.Length);
        string encodedString = Convert.ToBase64String(fileContents);

        Microsoft.Health.ItemTypes.File file = new Microsoft.Health.ItemTypes.File();
        file.Name = fileInfo.Name;
        file.Size = fileInfo.Length;
        file.ContentType =
    new CodableValue("image/jpg");
        file.OtherData =
    new OtherItemData();
        file.OtherData.ContentEncoding =
    file.OtherData.ContentType = @"image/jpg";

        file.OtherData.Data = encodedString;


    That will get the data up into HealthVault. Remember that the OtherData section doesn't come down by default, so if you want to get the contents of the file back, you'll need to specify:

    filter.View.Sections = HealthRecordItemSections.All;

    (or another version of the Sections mask that includes HealthRecordItems.OtherData).

  • Eric Gunnerson's Compendium

    HealthVault and openness


    Yesterday - while I was taking a day off skiing with my wife and daughter - we announced our plans around openness and interoperabiity for HealthVault.

    I'm pretty excited about this. I'm especially excited about making the current .NET client library available under the Microsoft reference license, as I remember how useful it was to step through the MFC or ATL source when I was trying to figure out how things worked (or, more usually, what I had done wrong).

  • Eric Gunnerson's Compendium

    Build a 3D XNA game from scratch - webcast series


    This came highly recommended...

    Build a 3D XNA game from scratch - webcast series

Page 1 of 1 (3 items)