Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

Create SPListItem from ZipArchiveEntry without FileStream

$
0
0

I'm a new .Net developper and i'm facing an issue while developping an Uploaded Zip File in a document Library.

i need to extract the content of the Zip File uploaded to do some actions on the files contained in it.

So i choosed to use ZipArchive Stream to handle my problem, i can retrieve my SPFile from my DocLib easily and create the stream from it.

But i'm not able to create embedded files from ZipArchiveEntry, i tried the following piece of code ( not a copy/past, i'm not on my dev machine )

foreach(SPFile myFile in mySPFolder.Files){ZipArchive myZip =newZipArchive(myFile.OpenBinaryStream());foreach(ZipArchiveEntry subZip inZipArchive.Entries){SPFile newFile =list.RootFolder.Add("myxml.xml",subZip.Open())}}

I'm facing an issue while creating my newFile as it's throwing me a System I/O error, as per my understanding it's maybe due to the fact that the stream returned by the method ZipArchiveEntry.Open() is a deflatestream.

I saw that the file creation can be done with a MemoryStream, but i'm not able to understand how to convert a deflatestream to a memorystream.

Thanks for your support,


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>