I'm receiving a .zip
file from a server.
The .zip
file is sent 64Base
encoded and it contains an XML file.
After I decode the data to binary using Convert.FromBase64String
, can I convert the byte array to XML?
I don't want to deal with unzipping.
I tried the following code: (that resulted in Gibberish that doesn't make any sense and doesn't look like XML at all)
XmlDocument doc = new XmlDocument();
string xml = Encoding.UTF8.GetString(buffer);
doc.LoadXml(xml);
Any ideas?
You say you don't want to unzip, but do you actually mean that you don't want to unzip to disc? Most zip libraries either allow you to unzip a file to a byte array directly or to a stream where you could pass it a MemoryStream.
There's no getting around having to uncompress. Unless you have control over the server side, then you could change the format to an uncompressed file (like a tar file). Then you wouldn't have to uncompress.
You say:
I'm receiving a .zip file from a server.
And:
I don't want to deal with unzipping.
Well. You have to. If the data is in a zip
archive, you need to extract it first. You can't just ignore the fact.
There are plenty of zip
libraries - sharpziplib is free and easy enough to use.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.