public StructuredStorageRoot(Stream stream) { try { this._storageRoot = (StorageInfo)StructuredStorageRoot.InvokeStorageRootMethod(null, "CreateOnStream", stream); } catch (Exception innerException) { throw new StructuredStorageException("Cannot get StructuredStorageRoot", innerException); } }
public StructuredStorageRoot(string fileName) { try { this._storageRoot = (StorageInfo)StructuredStorageRoot.InvokeStorageRootMethod(null, "Open", fileName, FileMode.Open, FileAccess.Read, FileShare.Read); } catch (Exception innerException) { throw new StructuredStorageException("Cannot get StructuredStorageRoot", innerException); } }
private static byte[] GetRawBasicFileInfo(string revitFileName) { if (!StructuredStorageUtils.IsFileStucturedStorage(revitFileName)) { throw new NotSupportedException("File is not a structured storage file"); } using (StructuredStorageRoot structuredStorageRoot = new StructuredStorageRoot(revitFileName)) { if (!structuredStorageRoot.BaseRoot.StreamExists("BasicFileInfo")) { throw new NotSupportedException(string.Format("File doesn't contain {0} stream", "BasicFileInfo")); } StreamInfo streamInfo = structuredStorageRoot.BaseRoot.GetStreamInfo("BasicFileInfo"); using (Stream stream = streamInfo.GetStream(FileMode.Open, FileAccess.Read)) { byte[] array = new byte[stream.Length]; stream.Read(array, 0, array.Length); return(array); } } }
private void CloseStorageRoot() { StructuredStorageRoot.InvokeStorageRootMethod(this._storageRoot, "Close"); }