-1

How do I extract multiple .gz file's (WinRar Archives) without knowing the name of the files? I get multiple log files created from an application I use which all get saved to an archive, which is saved to a separate folder. The only thing the archive contains is one .log file.

So all archives are in one folder, (nothing else is in this folder other than .gz files) which all contains one .log file, I want all of these .log files to be extracted to a separate folder using vb.net, is this possible?

Example Log Folder, C:\Logs, which contains multiple .gz archives, which each contains one .log file.

Extract to > C:\Extracted, which will then contain all of the .log files with their original names.

What I have tried:

I have tried this Link but it gives an error,

"ZipFile" is not declared, it may be inaccessible due to its protection level. (Yes I added the reference System.IO.Compression.FileSystem as stated in the msdn post.)

I have also tried the solution from this post, which works for .zip files, but not for .gz files which is what I need it for.

Joey
  • 33
  • 9
  • So there are a few "extraction" tools available to .Net, have you tried any? – Jeremy Thompson Nov 25 '16 at 01:30
  • @JeremyThompson I'm not aware of any, that's why i'm here asking for help. But by `extraction tools`, do you mean external/already made tools? If so, I need this to be apart of my vb.net project, so that may not be a solution for me if that's the case. – Joey Nov 25 '16 at 01:35
  • So you have seen this? http://stackoverflow.com/a/1348305/495455, you just use `GZipStream` - extracting from `c:\logs` to `c:\extracted` should be trivial. Can you try it please? Post the code when you have and point out any problems. – Jeremy Thompson Nov 25 '16 at 02:28
  • @JeremyThompson I'm honestly not even really sure where to start with that link, no matter what way I attempt it, it's giving out 10+ errors, most of it been errors like `FileStream, stream & GZipStream are class type's and cannot be used as an expression.` along with 6 files been inaccessible due to protection levels. Possibly this code is just for C#? Or perhaps I'm just translating it to vb.net incorrectly. – Joey Nov 25 '16 at 11:23
  • You can google *Telerik* **CodeConverter** to translate the code from VB.Net to C# or vice versa. What have you tried? There is no code, no research, no notes, just nothing in your question. – Jeremy Thompson Nov 25 '16 at 11:59
  • @JeremyThompson - Sorry about that, I had practically no sleep when making those posts / going over the code which was a bad idea, I just re-read the code and got it working, thanks! Can you post that link as an answer so I can accept it as the solution? – Joey Nov 25 '16 at 13:09

1 Answers1

0

I think this is what you want. Take a look at this.

http://www.codeproject.com/Tips/257193/Easily-zip-unzip-files-using-Windows-Shell32

Shadow Fiend
  • 351
  • 6
  • 18
  • This copied all the Archives from the main folder to the output folder, it doesn't seem to extract the archives. – Joey Nov 25 '16 at 01:50
  • @Joey stay tuned let me try to help you within this day. Try to find a source that suites you. – Shadow Fiend Nov 25 '16 at 02:04