How can I extract a file from a System.IO.Packaging.Package hosted on a URL, without downloading the package? RRS feed

  • Question

  • I need to get the stream associated with the file (if present) from a OPC based package hosted on a URL, without downloading the package, as the package could be >1GB as well. I just need an XML file from the package.

    I came across System.IO.Packaging.Package class which can work with packages (OPC based) but I am unable to find a way to extract a file without downloading the package.

    Is there any way I can get it working with non-seekable streams without downloading or copying stream to MemoryStream etc. Just to re-iterate I just need a small XML file from a huge (>1GB package).

    Thank you.

    • Edited by hemaanshu Monday, July 28, 2014 11:55 AM
    Monday, July 28, 2014 11:54 AM

All replies

  • Hi Hemaanshu,

    Based on my knowledge, I’ve not heard of this feature. To achieve your goal, I think you should unzip your file on server and then download the xml file. I find a way to read data from a zip file without having to unzipping. Try the method on the following link. http://stackoverflow.com/questions/5967864/how-to-read-data-from-a-zip-file-without-having-to-unzip-the-entire-file.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. <br/> Click <a href="http://support.microsoft.com/common/survey.aspx?showpage=1&scid=sw%3Ben%3B3559&theme=tech"> HERE</a> to participate the survey.

    Tuesday, July 29, 2014 2:22 AM
  • DotZipLib does not support non-seekable streams (...I tried ZipFile and ZipInputStream classes), hence I need to download the package which I do not want to as I described.

    There's another library called SharpZipLib which also has a ZipInputStream class which is able to extract file from a zip archive hosted on a web server but fails to do the same with OPC (Open Packaging Conventions) based package.

    Wednesday, July 30, 2014 4:44 AM