How to encode a zip file to base64 in C# and how to retrieve/decode it Node JS?
I have used the below code to convert base64 in C#
Byte[] bytes = File.ReadAllBytes("path of the file");
String file = Convert.ToBase64String(bytes);
I have used the below code to decode base64 save as a zip file
var fs = require('fs');
var buf = new Buffer(fs.readFileSync('decoded.txt'), 'base64');
fs.writeFileSync('test.zip', buf);
But when I trying to extract the zip file. zip is getting corrupted.
Performing encode/decoding with the same language zip file is not corrupting.
I have researched about it. In C# byte array to convert UTF-8 then base64. But I have no idea about the conversation where going wrong.
Please guide me. Particularly I don't have much idea about C#.
via Andan H M
No comments:
Post a Comment