private static byte[] getBytesForPOST(ConfigPOST config) { NiemXML niemXML = new NiemXML(); StringBuilder sb = new StringBuilder(); if (config.Base64FileName != null) { sb.Append(niemXML.getBeforeBase64(config.DocTitle)); string attachmentStr = File.ReadAllText(config.Base64FileName, Encoding.UTF8); //attachmentStr = Convert.ToBase64String(Encoding.UTF8.GetBytes(attachmentStr)); //String to Base64 //or strip newlines? attachmentStr = attachmentStr.Replace(System.Environment.NewLine, ""); sb.Append(attachmentStr); sb.Append(niemXML.getAfterBase64(attachmentStr.Length, config.AttachmentDescription, config.AttachmentFormatName, config.getAttachmentFileName())); attachmentStr = null; File.WriteAllText(ConfigPOST.OUT_DIR + config.getAttachmentFileName() + "(whole).xml", sb.ToString()); } else if (config.CompleteDocFileName != null) { sb.Append(File.ReadAllText(config.CompleteDocFileName, Encoding.UTF8)); } else { throw new Exception("config.Base64FileName or config.CompleteDocFileName must be set!"); } byte[] xmlData = System.Text.Encoding.UTF8.GetBytes(sb.ToString()); return(xmlData); }
private static byte[] getBytesForPOST(ConfigPOST config) { NiemXML niemXML = new NiemXML(); StringBuilder sb = new StringBuilder(); if (config.Base64FileName != null) { sb.Append(niemXML.getBeforeBase64(config.DocTitle)); string attachmentStr = File.ReadAllText(config.Base64FileName, Encoding.UTF8); //attachmentStr = Convert.ToBase64String(Encoding.UTF8.GetBytes(attachmentStr)); //String to Base64 //or strip newlines? attachmentStr = attachmentStr.Replace(System.Environment.NewLine, ""); sb.Append(attachmentStr); sb.Append(niemXML.getAfterBase64(attachmentStr.Length, config.AttachmentDescription, config.AttachmentFormatName, config.getAttachmentFileName())); attachmentStr = null; File.WriteAllText(ConfigPOST.OUT_DIR + config.getAttachmentFileName() + "(whole).xml", sb.ToString()); } else if (config.CompleteDocFileName != null) { sb.Append(File.ReadAllText(config.CompleteDocFileName, Encoding.UTF8)); } else { throw new Exception("config.Base64FileName or config.CompleteDocFileName must be set!"); } byte[] xmlData = System.Text.Encoding.UTF8.GetBytes(sb.ToString()); return xmlData; }