Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. zipping files in C#

zipping files in C#

Scheduled Pinned Locked Moved C#
csharpjavahelpquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    elena12345
    wrote on last edited by
    #1

    Hi, What library do you use to zip up files? I am using java.util.zip and it's giving me some problems. Everything works fine if WInZip is installed. However if you uninstall WinZip and it uses the Windows default compresser things don't work so well: the zip file is created but it's empty. Does anyone know a solution to this problem? Thanks, Elena Here is my code: ZipOutputStream m_zipstream; string filepath = @"C:\Elena\Junk\test\a.txt"; m_zipstream = new ZipOutputStream( new java.io.FileOutputStream( @"C:\Elena\Junk\test\zip.zip" ) ); ZipEntry currententry = new ZipEntry(filepath); currententry.setMethod(ZipEntry.DEFLATED); m_zipstream.putNextEntry(currententry); try { java.io.FileInputStream current = new java.io.FileInputStream(filepath); try { sbyte[] buffer = new sbyte[8192]; int buffercount; while ((buffercount = current.read(buffer, 0, buffer.Length)) > 0) m_zipstream.write(buffer, 0, buffercount); } finally { current.close(); } } finally { m_zipstream.closeEntry(); } m_zipstream.close(); m_zipstream = null; Elena

    J 1 Reply Last reply
    0
    • E elena12345

      Hi, What library do you use to zip up files? I am using java.util.zip and it's giving me some problems. Everything works fine if WInZip is installed. However if you uninstall WinZip and it uses the Windows default compresser things don't work so well: the zip file is created but it's empty. Does anyone know a solution to this problem? Thanks, Elena Here is my code: ZipOutputStream m_zipstream; string filepath = @"C:\Elena\Junk\test\a.txt"; m_zipstream = new ZipOutputStream( new java.io.FileOutputStream( @"C:\Elena\Junk\test\zip.zip" ) ); ZipEntry currententry = new ZipEntry(filepath); currententry.setMethod(ZipEntry.DEFLATED); m_zipstream.putNextEntry(currententry); try { java.io.FileInputStream current = new java.io.FileInputStream(filepath); try { sbyte[] buffer = new sbyte[8192]; int buffercount; while ((buffercount = current.read(buffer, 0, buffer.Length)) > 0) m_zipstream.write(buffer, 0, buffercount); } finally { current.close(); } } finally { m_zipstream.closeEntry(); } m_zipstream.close(); m_zipstream = null; Elena

      J Offline
      J Offline
      Judah Gabriel Himango
      wrote on last edited by
      #2

      Free one here[^] --------------------------- He who knows that enough is enough will always have enough. -Lao Tsu

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups