Pages

Monday, November 28, 2011

Create ZIP files from AX

I recently had to write a solution to create ZIP files from within AX 2012. Apparently such functionality is not very well implemented in standard .NET.

But the free DotNetZip .NET library works like a charm. Here's a link to the library on CodePlex: http://dotnetzip.codeplex.com/

6 comments:

Itachi said...

Hi,

could this be used in AX 2009 ?

I write a job but it fails when doing "save" the zip file.

would you kindly help ?

Palle Agermark said...

That should work with AX 2009 too. What's the error you're getting

Palle Agermark said...

Also, can I see your code

rajesh said...

Hi AgerMark,

Will you tel me the code part for creating zip in Ax2012.

Palle Agermark said...

Here is a short example:

Ionic.Zip.ZipFile zipFile;
System.String zipFileName;
str FileNameToZip;
...
zipFile = new Ionic.Zip.ZipFile();
...
zipFile.AddFile(FileNameToZip, '');
...
zipFileName = @'C:\Files2Zip\NewZipFile.zip';
zipFile.Save(zipFileName);

Also there is good documentation on the CodePlex site: http://dotnetzip.codeplex.com/

Raja Vignesh said...

In the same way how to un-zip the files in a zip file in ax 2009?