ZeroInstall.Publish.SignedCatalog.Save C# (CSharp) Method

Save() public method

Saves Catalog to an XML file, adds the default stylesheet and sign it it with SecretKey (if specified).
Writing and signing the catalog file are performed as an atomic operation (i.e. if signing fails an existing file remains unchanged).
A problem occurs while writing the file. Write access to the file is not permitted. The specified could not be found on the system. was incorrect.
public Save ( [ path, [ passphrase = null ) : void
path [ The file to save in.
passphrase [ The passphrase to use to unlock the secret key; can be null if is null.
return void
        public void Save([NotNull] string path, [CanBeNull] string passphrase = null)
        {
            #region Sanity checks
            if (string.IsNullOrEmpty(path)) throw new ArgumentNullException(nameof(path));
            #endregion

            if (SecretKey == null)
            {
                Catalog.SaveXml(path);
                return;
            }

            var openPgp = OpenPgpFactory.CreateDefault();
            using (var stream = new MemoryStream())
            {
                Catalog.SaveXml(stream, stylesheet: @"catalog.xsl");
                stream.Position = 0;

                FeedUtils.SignFeed(stream, SecretKey, passphrase, openPgp);
                stream.CopyToFile(path);
            }
            string directory = Path.GetDirectoryName(path);
            if (directory != null)
            {
                openPgp.DeployPublicKey(SecretKey, directory);
                FeedUtils.DeployStylesheet(directory, @"catalog");
            }
        }
        #endregion