Load multiple files in a row results in file_id -1 c#

So, as the title already explaines, i wanted to load a few files in a row, in order to refactor the content a bit and use it afterwards. The problem is, at loading the second file the file:id is not being returned by H5F.open , but instead i get the error number -1.
Ideally i would like to hold the files open and map the reference numbers of the datasets to a list to access them at will. The used Language is c#.

How many files did you open before this problem occurs? Under Windows there is an inherent limitation that only 2048 files can be opened at the same time when using the standard Windows POSIX file driver.

Already at the second file that i want to open, the problem occurs.

What i want to achieve is:

  • Select multiple files
  • Load the files in a row and do something with the loaded data
  • When data is loaded, also remember the reference of the dataset if the dataset is needed later again

The reuse of the dataset should then be like, if the modified dataset is needed, i open the files again and directly use the referenced ids to have less overhead.

But the problem is as stated even before i can do that.

It sounds like you are trying to close everything but then later use the old dataset ID to get the original dataset that it formerly referenced. That will not work. The ID is not a global reference to a dataset that is always valid - it’s a transient ID that is discarded when the dataset is closed. If you want to access the dataset after it has been closed, you will need to re-open the dataset using H5Dopen() and get a new ID.

Hmmm, this could be a problem later, okay. But, if i have a for loop, where i allocate the fileID in the beginning, and then just work with data later, then why is the fileID == -1 ?

long fileId = -1;



                fileId = H5F.open(Path, H5F.ACC_RDONLY);





This should always, if the file is correct, give me the proper fileID, but on the second iteration i get a -1. This is even when i close the old fileID at the end of the loop.

I think I need to see more code to understand what is going wrong.

One of the files i got from my colleagues was messed up in one point, which did result in an error, and now it works.

However the problem with the references you mentioned only occurs, if you have direct references. If i take the H5O.open_by_addr(file_id, some_ulong) where some_ulong is a subreference in the file , then you will get
a dataset_id that allows you to directly jump to the point where the data is being positioned. At least as far as i tested it.

Regards, Markus