c# - Add XML file to ZIP -
issue
i have been given old piece of code (5+ years) , have been adding functioanlity application. have come across issue , xml file not correctly getting added zip. when check zip after xml file appear 0 data.
code
so create xml , add correct data file:
using (isolatedstoragefilestream doc = localstorage.openfile(xmlfile, filemode.open)) { //add code populate xml file. works fine. }
then open xml , create zip , trying add xml zip:
note: there line under 'zippackage' says "the class has been deprecated"
using (isolatedstoragefilestream filestream = localstorage.openfile(xmlfile, filemode.open)) { using (isolatedstoragefilestream zipstream = localstorage.createfile(zipfile)) { using (zippackage zippackage = zippackage.create(zipstream)) { zippackage.addstream(filestream, xmlfile, zipcompression.deflate64, datetime.now); zippackage.close(true); } } }
then copy bytes file:
using (isolatedstoragefilestream zipstream = localstorage.openfile(zipfile, filemode.open)) { filedata = new byte[zipstream.length]; zipstream.read(filedata, 0, filedata.length); zipstream.close(); }
when debug xml file created has information in file needed. when added zip looses data.
edit: 'zippackage' telerik , using windows 7. changing way file compressed work.
Comments
Post a Comment