public static void ToXml(string inputFile, string outFile) { using (System.IO.MemoryStream f = new System.IO.MemoryStream(System.IO.File.ReadAllBytes(inputFile), false)) { Asn1Object root = new TAP_0311_DNA.RootNode(); root.Decode(f, CSharpAsn1CRT.EncodingRules.CER); XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.OmitXmlDeclaration = true; settings.CheckCharacters = false; // using (StreamWriterLevel of = new StreamWriterLevel(outFile)) using (XmlWriter xw = XmlTextWriter.Create(outFile, settings)) { string attrs = string.Format("Version=\"{0}\" Release=\"{1}\"", 3, 11); root.ToXml(xw, "TAP3-DNA", new KeyValuePair<string, string>("Version", "3"), new KeyValuePair<string, string>("Release", "11")); } } }
public static void ToBer(string inputFile, string outFile) { Asn1Object root = new TAP_0311_DNA.RootNode(); using (System.IO.MemoryStream f = new System.IO.MemoryStream(System.IO.File.ReadAllBytes(inputFile), false)) { root.FromXml(f, "TAP3-DNA", null); } using (System.IO.FileStream w = new System.IO.FileStream(outFile, System.IO.FileMode.Create)) { root.Encode(w, CSharpAsn1CRT.EncodingRules.CER); } }