private StorageInfo CreateStorage(string name)
 {
     // Create new StorageInfo
     StorageInfo newSubStorage = new StorageInfo( this, name );
 
     // Make it real
     if( !newSubStorage.InternalExists(name) )
     {
         /* TBD
         if( !CU.IsValidCompoundFileName(name))
         {
             throw new IOException(
                     SR.Get(SRID.UnableToCreateStorage),
                     new COMException( 
                         SR.Get(SRID.NamedAPIFailure, "IStorage.CreateStorage"), 
                         nativeCallErrorCode ));
             }
             */
         // It doesn't already exist, please create.
         StorageInfoCore newStorage = core.elementInfoCores[ name ] as StorageInfoCore;
         Invariant.Assert( null != newStorage);
 
         int nativeCallErrorCode = core.safeIStorage.CreateStorage(
                     name, 
                 (GetStat().grfMode & SafeNativeCompoundFileConstants.STGM_READWRITE_Bits)
                     | SafeNativeCompoundFileConstants.STGM_SHARE_EXCLUSIVE,
                 0,
                 0,
             #pragma warning suppress 6506 // Invariant.Assert(null != newStorage)
             out newStorage.safeIStorage );
         if( SafeNativeCompoundFileConstants.S_OK != nativeCallErrorCode )
         {
             if( nativeCallErrorCode == SafeNativeCompoundFileConstants.STG_E_ACCESSDENIED )
             {
                 throw new UnauthorizedAccessException(
                         SR.Get(SRID.CanNotCreateAccessDenied),
                         new COMException( 
                         SR.Get(SRID.NamedAPIFailure, "IStorage.CreateStorage"), 
                         nativeCallErrorCode ));
             }
             else
             {
                 throw new IOException(
                     SR.Get(SRID.UnableToCreateStorage),
                     new COMException( 
                         SR.Get(SRID.NamedAPIFailure, "IStorage.CreateStorage"), 
                         nativeCallErrorCode ));
             }
         }
 
         // Invalidate enumerators
         InvalidateEnumerators();
     }
     else
     {
         throw new IOException(SR.Get(SRID.StorageAlreadyExist));
     }
 
     // Return a reference
     return newSubStorage;
 }
  /// <summary>
 /// Checks if a storage exists by the passed name.
 /// </summary>
 /// <param name="name">Name of storage</param>
 /// <returns>Reference to new storage</returns>
 public bool SubStorageExists(string name)
 {
     StorageInfo storageInfo = new StorageInfo(this, name);
     return storageInfo.InternalExists(name);
 }
    /// <summary>
    /// Deletes a storage recursively.
    /// </summary>
    /// <param name="name">Name of storage</param>
    public void DeleteSubStorage(string name)
    {
        CheckDisposedStatus();

         //check the arguments
        if( null == name )
            throw new ArgumentNullException("name");

        StorageInfo storageInfo = new StorageInfo(this, name);
        if (storageInfo.InternalExists(name))
        {
            InvalidateEnumerators();
            // Go ahead and delete "this" storage
            DestroyElement( name );
        }
        //We will not throw exceptions if the storage does not exist. This is to be consistent with Package.DeletePart.
    }
    /// <summary>
    /// Returns the storage by the passed name.
    /// </summary>
    /// <param name="name">Name of storage</param>
    /// <returns>Reference to the storage</returns>
    public StorageInfo GetSubStorageInfo(string name)
    {
        //Find if this storage exists
        StorageInfo storageInfo = new StorageInfo(this, name);

        if (storageInfo.InternalExists(name))
        {
            return storageInfo;
        }
        else
        {
            throw new IOException(SR.Get(SRID.StorageNotExist));
        }
    }