//Make sure that the access modes for the container and the part are compatible
        private void ThrowIfOpenAccessModesAreIncompatible(FileMode mode, FileAccess access)
        {
            Package.ThrowIfFileModeInvalid(mode);
            Package.ThrowIfFileAccessInvalid(access);

            //Creating a part using a readonly stream.
            if (access == FileAccess.Read &&
                (mode == FileMode.Create || mode == FileMode.CreateNew || mode == FileMode.Truncate || mode == FileMode.Append))
            {
                throw new IOException(Resources.UnsupportedCombinationOfModeAccess);
            }

            //Incompatible access modes between container and part stream.
            if ((_container.FileOpenAccess == FileAccess.Read && access != FileAccess.Read) ||
                (_container.FileOpenAccess == FileAccess.Write && access != FileAccess.Write))
            {
                throw new IOException(Resources.ContainerAndPartModeIncompatible);
            }
        }