8 Replies - 648 Views - Last Post: 27 December 2011 - 05:19 AM Rate Topic: -----

#1 blasterweb  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 22-December 11

Copy archive to another archive without deleting existing content

Posted 24 December 2011 - 11:27 AM

Hey there

How exactly do you copy the content of a .rar/.zip file (from your resources) to an archive in the computer? (.jar - Java Archive)
I mean without deleting existing data on the .jar file already. I use this code currently.
The TestArchive is a .zip file, and when I press the button, it extracts the content of TestArchive to the .jar arhive, but deletes everything that was already inside the .jar archive.

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
System.IO.File.WriteAllBytes(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\test\test.jar", My.Resources.TestArchive)
    End Sub


Is This A Good Question/Topic? 0
  • +

Replies To: Copy archive to another archive without deleting existing content

#2 blasterweb  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 22-December 11

Re: Copy archive to another archive without deleting existing content

Posted 24 December 2011 - 03:29 PM

Is it possible? I have searched for it for a very long time now, but none of the codes work :(
Was This Post Helpful? 0
  • +
  • -

#3 DimitriV  Icon User is offline

  • Don't try to save yourself… the circle is complete
  • member icon

Reputation: 544
  • View blog
  • Posts: 2,632
  • Joined: 24-July 11

Re: Copy archive to another archive without deleting existing content

Posted 24 December 2011 - 06:35 PM

WriteAllLines, WriteAllText and WriteAllBytes all overwrite existing file contents, hence the "WriteAll" bit.
Use a StreamWriter or something like that.
http://www.google.co...to+files+vb.net
Was This Post Helpful? 0
  • +
  • -

#4 blasterweb  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 22-December 11

Re: Copy archive to another archive without deleting existing content

Posted 26 December 2011 - 06:22 AM

View PostjimmyBo, on 24 December 2011 - 06:35 PM, said:

WriteAllLines, WriteAllText and WriteAllBytes all overwrite existing file contents, hence the "WriteAll" bit.
Use a StreamWriter or something like that.
http://www.google.co...to+files+vb.net

Doesn't that only work for text files? I need to put the content of a .zip file in my resources to a .jar file.
Was This Post Helpful? 0
  • +
  • -

#5 ricardosms  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 73
  • View blog
  • Posts: 297
  • Joined: 02-April 10

Re: Copy archive to another archive without deleting existing content

Posted 26 December 2011 - 07:01 AM

A jar file is basically the same as a zip archive. Windows Explorer sees zip archives as compressed folders. Using explorer you could add files or folders to that archive. Maybe something on that direction may work, like adding or extracting to same place and compressing again?. Check compression using shell32.dll
Was This Post Helpful? 1
  • +
  • -

#6 blasterweb  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 22-December 11

Re: Copy archive to another archive without deleting existing content

Posted 26 December 2011 - 07:40 AM

View Postricardosms, on 26 December 2011 - 07:01 AM, said:

A jar file is basically the same as a zip archive. Windows Explorer sees zip archives as compressed folders. Using explorer you could add files or folders to that archive. Maybe something on that direction may work, like adding or extracting to same place and compressing again?. Check compression using shell32.dll

Thanks man. I just Googled it and found a thread of yours. I'll try to understand it :P and figure out how to extract from resources,
Was This Post Helpful? 0
  • +
  • -

#7 blasterweb  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 22-December 11

Re: Copy archive to another archive without deleting existing content

Posted 26 December 2011 - 05:19 PM

View PostjimmyBo, on 24 December 2011 - 06:35 PM, said:

WriteAllLines, WriteAllText and WriteAllBytes all overwrite existing file contents, hence the "WriteAll" bit.
Use a StreamWriter or something like that.
http://www.google.co...to+files+vb.net

View Postricardosms, on 26 December 2011 - 07:01 AM, said:

A jar file is basically the same as a zip archive. Windows Explorer sees zip archives as compressed folders. Using explorer you could add files or folders to that archive. Maybe something on that direction may work, like adding or extracting to same place and compressing again?. Check compression using shell32.dll


Alright so this is what I plan to do. Just wanna hear if there is an easier method to do it.
The program must: Exctract a .zip file from My Resources to a .jar file (extract it to inside the .jar file)

So this is what the progream is going to do:
1. Rename the extension ".jar" of the file to ".zip".
2. Now extract it to a temp folder
3. Extract my resource to another temp folder
4. Copy the content of the temp folder made by My Resources to the renamed extention temp folder
5. Zip the folder to a ".zip" file
6. Rename the ".zip" file to ".jar".

Are there easier ways to do this? (I got DotNetZip, which I use for zip/unzip)
Was This Post Helpful? 0
  • +
  • -

#8 ricardosms  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 73
  • View blog
  • Posts: 297
  • Joined: 02-April 10

Re: Copy archive to another archive without deleting existing content

Posted 27 December 2011 - 05:07 AM

That is basically what I woul do.
Just a couple of highlights. I see that you intend to use two temporary folders. Are you compressing the two folders or just the files. If you are compressing the files only, are there chances that some files already have the same name and are to be overwritten? If that is the case, you should provide a mechanism to do that without causing a file access exception.
Was This Post Helpful? 0
  • +
  • -

#9 ricardosms  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 73
  • View blog
  • Posts: 297
  • Joined: 02-April 10

Re: Copy archive to another archive without deleting existing content

Posted 27 December 2011 - 05:19 AM

After posting I just thought of something else that you may like to consider.
You don't need to uncompress a zip archive if you were to use the shell32 mechanism. The system sees it like a regular folder, you just copy to it and the files are compressed on the fly.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1