PackagePart.GetStream().Write help?
If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
5 posts
Page 1 of 1
Hello,
Here is the code I am using:
I am trying to write a bunch of .class files to a .jar file containing more .class files. When I go and open up the .jar file with 7zip, I notice that all of the .class files that WERE there are now gone.
How can I fix this? Anyone?
~GoodGuy17
Here is the code I am using:
Code: Select all
On the last part of that, I get an error saying, "Buffer of bytes to be written is too small."Private Sub AddToArchive(ByVal zip As Package, ByVal fileToAdd As String)
Dim uriFileName As String = fileToAdd.Replace(" ", "_")
Dim zipUri As String = String.Concat("/", IO.Path.GetFileName(uriFileName))
Dim partUri As New Uri(zipUri, UriKind.Relative)
Dim contentType As String = Net.Mime.MediaTypeNames.Application.Zip
Dim pkgPart As PackagePart = zip.CreatePart(partUri, contentType, CompressionOption.Normal)
Dim bites As Byte() = File.ReadAllBytes(fileToAdd)
Dim inf As New FileInfo(zipPath)
Dim filesize As Integer = inf.Length
pkgPart.GetStream().Write(bites, filesize, bites.Length)
End Sub
I am trying to write a bunch of .class files to a .jar file containing more .class files. When I go and open up the .jar file with 7zip, I notice that all of the .class files that WERE there are now gone.
How can I fix this? Anyone?
~GoodGuy17

I think you are trying to make a minecraft modder
Anyway, if its a .jar don't put byval zip, put byval jar.

kolega28 wrote:I think you are trying to make a minecraft modderDoesn't it work all the same? The files DO make it into the .jar, they're just 0 bytes and all the other files are gone.Anyway, if its a .jar don't put byval zip, put byval jar.
Replace the last line with
Code: Select all
Or
pkgPart.GetStream().Write(bites, filesize, bites.Length - 1)
Code: Select all
pkgPart.GetStream().Write(bites, 0, bites.Length - 1)
LMAOSHMSFOAIDMT
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;
Over 30 projects with source code!
Please give reputation to helpful members!
![Image]()
![Image]()
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;
Over 30 projects with source code!
Please give reputation to helpful members!

MrAksel wrote:Replace the last line withThat stopped the error, but it still deleted everything else in the .jar, leaving only a few folders and the .class files we told it to install/inject/import.Code: Select allOrpkgPart.GetStream().Write(bites, filesize, bites.Length - 1)
Code: Select allpkgPart.GetStream().Write(bites, 0, bites.Length - 1)
5 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023