Advertisement
SpoOkyMagician

Untitled

Jan 7th, 2025
766
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VisualBasic 2.25 KB | Source Code | 0 0
  1. Imports System
  2. Imports System.IO
  3. Imports System.IO.Compression
  4. Imports System.Security.Cryptography
  5.  
  6. Module Program
  7.  
  8.     Function F_Decompress_File(my_in_file As String, my_out_file As String) As Object
  9.  
  10.         Dim toDecompress As Byte()
  11.         Dim nowDecompressed As Byte()
  12.         toDecompress = File.ReadAllBytes(my_in_file)
  13.  
  14.         Using inputStream As New MemoryStream(toDecompress)
  15.  
  16.             Using outputStream As New MemoryStream()
  17.  
  18.                 Using decompressionStream As New DeflateStream(inputStream, CompressionMode.Decompress)
  19.  
  20.                     decompressionStream.CopyTo(outputStream)
  21.  
  22.                 End Using
  23.  
  24.                 nowDecompressed = outputStream.ToArray
  25.  
  26.             End Using
  27.  
  28.         End Using
  29.  
  30.         File.WriteAllBytes(my_out_file, nowDecompressed)
  31.         Return Nothing
  32.  
  33.     End Function
  34.  
  35.     Function F_Compress_File(my_in_file As String, my_out_file As String) As Object
  36.  
  37.         Dim toCompress As Byte()
  38.         Dim nowCompressed As Byte()
  39.         toCompress = File.ReadAllBytes(my_in_file)
  40.  
  41.         Using inputStream As New MemoryStream(toCompress)
  42.  
  43.             Using outputStream As New MemoryStream()
  44.  
  45.                 Using compressionStream As New DeflateStream(outputStream, CompressionMode.Compress)
  46.  
  47.                     inputStream.CopyTo(compressionStream)
  48.  
  49.                 End Using
  50.  
  51.                 nowCompressed = outputStream.ToArray()
  52.                 File.WriteAllBytes(my_out_file, nowCompressed)
  53.  
  54.             End Using
  55.  
  56.         End Using
  57.  
  58.         Return Nothing
  59.  
  60.     End Function
  61.  
  62.     Sub Main()
  63.  
  64.         ' http://pont.ist/vbnet-compress-decompress-byte-array/
  65.        ' F_Compress_File("D:\scenario_tests\_ALL_SCENARIO_STUFF_OBJECTS_MINUS_HEADER_EDIT_TRIGGERS.aoe2scenario", "D:\scenario_tests\_ALL_SCENARIO_STUFF_OBJECTS_MINUS_HEADER_EDIT_TRIGGERS_OUTPUT.aoe2scenario")
  66.        ' F_Decompress_File("D:\scenario_tests\_ALL_SCENARIO_STUFF_OBJECTS_MINUS_HEADER_OUTPUT.aoe2scenario", "D:\scenario_tests\_ALL_SCENARIO_STUFF_OBJECTS_MINUS_HEADER.aoe2scenario") ' we need to reverse this...
  67.        F_Decompress_File("D:\SteamLibrary\steamapps\common\AoE2DE\wwise\Base.pck", "C:\Users\jerem\OneDrive\Base_output.pck") ' we need to reverse this...
  68.  
  69.     End Sub
  70.  
  71. End Module
  72.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement