/// <summary> /// Creates a new KmzFile using the data specified in the KmlFile. /// </summary> /// <param name="kml">The Kml data to add to the archive.</param> /// <returns> /// A new KmzFile populated with the data specified in the KmlFile. /// </returns> /// <remarks> /// This overloaded version does not resolve any links in the Kml data /// and, therefore, will not add any local references to the archive. /// </remarks> /// <exception cref="ArgumentNullException">kml is null.</exception> public static KmzFile Create(KmlFile kml) { Check.IsNotNull(kml, nameof(kml)); var instance = new KmzFile(); ZipArchiveEntry entry = instance.zip.CreateEntry(DefaultKmlFilename); using (Stream stream = entry.Open()) { kml.Save(stream); } return(instance); }
/// <summary> /// Creates a new KmzFile using the data specified in the KmlFile. /// </summary> /// <param name="kml">The Kml data to add to the archive.</param> /// <returns> /// A new KmzFile populated with the data specified in the KmlFile. /// </returns> /// <remarks> /// This overloaded version does not resolve any links in the Kml data /// and, therefore, will not add any local references to the archive. /// </remarks> /// <exception cref="ArgumentNullException">kml is null.</exception> public static KmzFile Create(KmlFile kml) { if (kml == null) { throw new ArgumentNullException("kml"); } var instance = new KmzFile(new MemoryStream()); instance._zip = new ZipFile(); // Add the Kml data using (var stream = new MemoryStream()) { kml.Save(stream); instance.AddFile(DefaultKmlFilename, stream.ToArray()); } return(instance); }