Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.


The closing of the h5m file is done via the dispose methods. To ensure that the file is closed at a specific time, the Dispose method should be called explicitly.

Reading file

H5M file reader object 

All the functionality for reading a h5m file is in the Hdf5FileReader class. Below is an example on creating an object of that type

Code Block
Hdf5FileReader h5MFileReader = Hdf5FileReader.Open(fileName);

List of properties

Code Block
// Definition
public void GetAllAttributeNames(string objectName, out List<string> attributeNames)

// Use example
List<string> attributeNames;
h5MFileReader.GetAllAttributeNames("/Complete metadata/Base", out attributeNames);

Dataset values

Below there is an example on using the method for reading the values of a dataset

Code Block
// Definition
        /// <summary>
        /// Read an 1-dimension dataset
        /// </summary>
        /// <typeparam name="T">the type of the elements in the dataset</typeparam>
        /// <param name="datasetPath">the path to the dataset in the hdf file</param>
        /// <param name="dataSet">an Array containing the values of the dataset</param>
        /// <exception cref="ArgumentException">the datasetPath needs to have a value where to read from</exception>
        /// <exception cref="InvalidOperationException">Thrown when it failed ot open the dataset</exception>
        /// <exception cref="IndexOutOfRangeException">the size (length) of the dataset could not be read properly</exception>
        public void ReadDataset<T>(string datasetPath, out Array dataSet)

// Use example
            Array dataset;
            h5MFileReader.ReadDataset<double>("/Complete metadata/Base", out dataset);