// // Methods // public void SaveText() { try { Encoding encoding = Encoding.Unicode; savedata = Convert.ToBase64String( CompressUtility.Compress(encoding.GetBytes(text)) ); } catch (Exception E) { Log.ErrorOnce("Unable to encode memorial data for " + ThingID + ": " + E.ToString(), ThingID.GetHashCode()); } }
public IPackage Create(string path) { var result = new Package { _title = Title, _author = Author, _version = Version, _signature = Signature, _datas = Datas }; using (var fileStream = File.Open(path, FileMode.Create)) using (var binaryWriter = new BinaryWriter(fileStream)) using (var zipStream = new ZipOutputStream(fileStream)) { // 헤더 데이터 작성 binaryWriter.Write(SectionType.Header.GetValue <ValueAttribute, string>()); binaryWriter.Write(result.Title ?? string.Empty); binaryWriter.Write(result.Author ?? string.Empty); binaryWriter.Write(result.Version ?? string.Empty); binaryWriter.Write(result.Signature ?? string.Empty); // 압축 스트림 설정 zipStream.SetLevel(3); // 압축 데이터 작성 binaryWriter.Write(SectionType.Content.GetValue <ValueAttribute, string>()); foreach (var data in Datas) { CompressUtility.Compress(zipStream, data); } zipStream.IsStreamOwner = false; zipStream.Close(); } return(result); }