public void RemoveCustomPart(XmlPart partType)
        {
            if (Parts == null)
            {
                return;
            }

            for (var i = Parts.Count - 1; i >= 0; i--)
            {
                if (Parts[i].PartType != partType)
                {
                    continue;
                }

                var part = Parts[i];
                part.Remove();

                Parts.RemoveAt(i);

                UnderlyingPackage.Flush();
                IsDirty = true;
            }
        }
        public void Save(string?customFileName = null, bool preserveAttributes = true)
        {
            if (string.IsNullOrEmpty(customFileName))
            {
                customFileName = Name;
            }

            if (!IsDirty && customFileName == Name)
            {
                return;
            }

            UnderlyingPackage.Flush();
            UnderlyingPackage.Close();

            var info = new FileInfo(customFileName);

            if (info.Exists)
            {
                File.SetAttributes(customFileName, FileAttributes.Normal);
            }

            try
            {
                File.Copy(_tempFileName, customFileName, true /*overwrite*/);
                if (info.Exists && preserveAttributes)
                {
                    File.SetAttributes(customFileName, info.Attributes);
                }
            }
            finally
            {
                Init();
            }

            IsDirty = false;
        }