public void Open(string fileName, OpenMode openMode) { if (fileName == null) { throw new ArgumentNullException(nameof(fileName)); } if (isOpened) { throw new InvalidOperationException("File system is already opened"); } storage = blockStorageFactory.Create(fileName); storage.Open(openMode); try { FSHeader header; if (openMode == OpenMode.Create) { header = CreateFile(); } else { var headers = new FSHeader[1]; storage.ReadBlock(0, headers); header = headers[0]; } InitializeFromHeader(storage, header); } catch { storage.Dispose(); } isOpened = true; }