/// <summary>Creates the archive</summary> /// <param name="sourcePath">The path to create the archive from.</param> public void WriteArchive(string sourcePath) { if (File.Exists(this.ArchiveFilePath)) File.Delete(this.ArchiveFilePath); FastZip fastZip = new FastZip(); fastZip.CreateZip(this.ArchiveFilePath, sourcePath, true, null); ArchiveMeta meta = new ArchiveMeta(); string contents = Serialize(meta); File.WriteAllText(this.ConfigFilePath, contents); }
private string Serialize(ArchiveMeta meta) { var serializer = new DataContractJsonSerializer(typeof(ArchiveMeta)); var stream = new MemoryStream(); serializer.WriteObject(stream, meta); stream.Position = 0; var sr = new StreamReader(stream); return sr.ReadToEnd(); }