Beispiel #1
0
        /// <summary>
        /// Closes the underlying package after saving it to the specified file.
        /// </summary>
        /// <param name="path">File system path where the package will be written.</param>
        public void CloseWrite(string path)
        {
            FileStream fs = null;

            if (package == null)
            {
                throw new InvalidOperationException("Package already closed.");
            }

            try
            {
                fs = new FileStream(path, FileMode.Create);
                package.Close(false);

                bs.Position = 0;
                bs.CopyTo(fs, (int)bs.Length);
            }
            finally
            {
                if (fs != null)
                {
                    fs.Close();
                }

                bs.Close();
            }
        }