mibuso.com

Microsoft Business Solutions online community
It is currently Wed May 22, 2013 9:20 pm

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 29 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Zip/Compress files in C/SIDE
PostPosted: Thu Apr 17, 2003 12:19 pm 
Offline
MVP Microsoft Dynamics NAV
NAV TechDays 2013 attendee

Joined: Fri Dec 06, 2002 11:50 am
Posts: 3390
Location: Kontich, Belgium
Country: Belgium (be)
I would have to compress all files within a specific folder. Does anyone know how I can do this from within Navision C/SIDE. May be there is some kind of OCX or Automation Server I can use. I thought of using pkzip in a SHELL-command, but isn't there a better solution?

_________________

Eric Wauters
MVP - Microsoft Dynamics NAV
My blog


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 17, 2003 12:27 pm 
Offline
Site Admin
MVP Microsoft Dynamics NAV
NAV TechDays 2013 attendee

Joined: Sun Nov 07, 1999 8:01 am
Posts: 3293
Location: Wilrijk
Country: Belgium (be)
Have a look at zlib http://www.gzip.org/zlib/
A DLL of this compression library can be found at http://www.winimage.com/zLibDll/

I did not try this, but maybe you can call this DLL from C/AL code.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 17, 2003 12:58 pm 
Offline
MVP Microsoft Dynamics NAV
NAV TechDays 2013 attendee

Joined: Fri Dec 06, 2002 11:50 am
Posts: 3390
Location: Kontich, Belgium
Country: Belgium (be)
Probably this is a stupid question, but I do not seem to succeed in registring the dll with regsvr32. I get the message "zlib.dll was loaded, but the DllRegisterServer entry point was not found."

Can you help me with this?


Luc Van Dyck wrote:
Have a look at zlib http://www.gzip.org/zlib/
A DLL of this compression library can be found at http://www.winimage.com/zLibDll/

I did not try this, but maybe you can call this DLL from C/AL code.

_________________

Eric Wauters
MVP - Microsoft Dynamics NAV
My blog


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 17, 2003 1:49 pm 
Offline
Site Admin
MVP Microsoft Dynamics NAV
NAV TechDays 2013 attendee

Joined: Sun Nov 07, 1999 8:01 am
Posts: 3293
Location: Wilrijk
Country: Belgium (be)
I searched a while and found this page http://www.dogma.net/markn/FAQ.html#Q27 where you can download zlibocx2.dll. This file can be registered using regsvr32.

Some C/AL code:

Code: Select all
x.InputFileName := 'd:\words_dutch.txt';
x.OutputFileName := 'd:\words_dutch.zip';
x.Compress;

x.InputFileName := 'd:\words_dutch.zip';
x.OutputFileName := 'd:\words_dutch2.txt';
x.Decompress;


where x is a OCX-variabele, pointing to "zlibIF Class".


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 17, 2003 2:15 pm 
Offline
MVP Microsoft Dynamics NAV
NAV TechDays 2013 attendee

Joined: Fri Dec 06, 2002 11:50 am
Posts: 3390
Location: Kontich, Belgium
Country: Belgium (be)
Thanks for your time!

I was looking too for some OCX-possibilities, and one I found:http://www.freedownloadscenter.com/Programming/Visual_Basic_Components_H-P/Maquisistem_Zip_Compress_OCX.html. Now, this always shows a Pop-up, and it didn't seem to work properly (I always got an error 'bad file name' or something).

Now, I'm trying your possibility, but here, it seems that I only can compress 1 file to 1 zip-file. Now, my main intention was compressing a folder to one file (because, later on, I have to e-mail this file).

_________________

Eric Wauters
MVP - Microsoft Dynamics NAV
My blog


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 17, 2003 2:58 pm 
Offline
MVP Microsoft Dynamics NAV
NAV TechDays 2013 attendee

Joined: Fri Dec 06, 2002 11:50 am
Posts: 3390
Location: Kontich, Belgium
Country: Belgium (be)
A solution COULD be the following:
Code: Select all
vZipFile := vDirectory + 'NameZipfile.zip';

vZipCommand := 'pkzip ' + vZipFile + ' ' + vDirectory + '*.html';

SHELL(vZipCommand);


Now, this has as major disadvantage that it is a DOS-routine, which means, that it can't use the long Windows-names. E.g. "Waldos zip file.html" becomes something like "waldos~1.HTM". Also the zip-file itself can't have a long file-name. So, if possible, I would prefer another solution.

_________________

Eric Wauters
MVP - Microsoft Dynamics NAV
My blog


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 17, 2003 3:31 pm 
Offline
Site Admin
MVP Microsoft Dynamics NAV
NAV TechDays 2013 attendee

Joined: Sun Nov 07, 1999 8:01 am
Posts: 3293
Location: Wilrijk
Country: Belgium (be)
What version of pkzip are you using? Version 4.00 DOES support long filenames.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 17, 2003 4:47 pm 
Offline
MVP Microsoft Dynamics NAV
NAV TechDays 2013 attendee

Joined: Fri Dec 06, 2002 11:50 am
Posts: 3390
Location: Kontich, Belgium
Country: Belgium (be)
Indeed, I was using 2.50.
I found a better pkzip now at http://burks.brighton.ac.uk/burks/software/compress/install.sw?3.cutezip2.exe. It's not pkzip, but pkzipc and works slightly different. Here is my code:
Code: Select all
vZipFile := vDirectory + 'ZipFile.zip';
vZipCommand := 'pkzipc -add ' + vZipFile + ' ' + vDirectory + '*.html';
SHELL(vZipCommand);


Thanks for the help!

_________________

Eric Wauters
MVP - Microsoft Dynamics NAV
My blog


Top
 Profile  
 
 Post subject: ZIP OCX - Binarywork
PostPosted: Tue Apr 22, 2003 11:01 am 
Offline

Joined: Tue Aug 20, 2002 7:01 am
Posts: 6
Location: Krefeld, Germany
Country: Germany (de)
Hi! I'm using the Zip Compress OCX from Binarywork in version 3.0.98. Works fine.


Top
 Profile E-mail  
 
 Post subject:
PostPosted: Wed Jun 07, 2006 9:17 am 
Offline
MVP Microsoft Dynamics NAV
NAV TechDays 2013 attendee

Joined: Fri Dec 06, 2002 11:50 am
Posts: 3390
Location: Kontich, Belgium
Country: Belgium (be)
These posts are from 3 years ago ... are there new (free) possibilities to ZIP files from Navision?

_________________

Eric Wauters
MVP - Microsoft Dynamics NAV
My blog


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 04, 2006 1:24 pm 
Offline

Joined: Tue Jun 27, 2006 10:38 am
Posts: 2
Location: Padova
Country: Italy (it)
You can use "Microsoft Shell Controls And Automation" to zip an entire folder. Parse FolderItems for specified files.

Code: Select all
//Variable
IntegerValue   Integer      
i   Integer      
Shell32   Automation   'Microsoft Shell Controls And Automation'.Shell   
SrcFolder   Automation   'Microsoft Shell Controls And Automation'.Folder   
DstFolder   Automation   'Microsoft Shell Controls And Automation'.Folder   
SrcItems   Automation   'Microsoft Shell Controls And Automation'.FolderItems3   
TextFile   File      
ZipFileName   Text      1024
SourceFolderName   Text      1024



//Code

//Zip file Initialization
TextFile.CREATE(ZipFileName);
TextFile.TEXTMODE(FALSE);

IntegerValue:=101010256;
TextFile.WRITE(IntegerValue);
IntegerValue:=0;
FOR i:=1 TO 9 DO
  TextFile.WRITE(IntegerValue);

TextFile.CLOSE;

IF CREATE(Shell32) THEN;
SrcFolder:=Shell32.NameSpace(SourceFolderName);
DstFolder:=Shell32.NameSpace(ZipFileName);
SrcItems:=SrcFolder.Items;
DstFolder.CopyHere(SrcItems);


You can find 'Microsoft Shell Controls And Automation' in all Microsoft Windows computer from W95. \:D/


Top
 Profile  
 
 Post subject: Works only on WindowsXP/2003
PostPosted: Fri Jan 05, 2007 4:47 pm 
Offline

Joined: Tue Jul 18, 2006 12:08 pm
Posts: 19
Location: Somewhere
Country: Latvia (lv)
Previous way of compressing file is pretty good and simple. But You must take care that compressed folders are supported only in XP/2003 Windows versions. For 98/ME/2000 You need to register additional DLL's which could be taken from MS udpate site (searching here)
After this, copy files from downloaded file: zipfldr.dll,dunzip32.dll and dzip32.dll into Windows\System or Windows\System32 (depends on OS) directory and register zipfldr.dll with regserv:
regserv32 X:\windows\system32\zipfldr.dll
Should work:)
Thanks for the way described.
Maybe somebody tried using CAB?:)


Top
 Profile  
 
 Post subject: Trying to use Microsoft Shell Controls And Automation"
PostPosted: Fri Feb 02, 2007 11:52 am 
Offline

Joined: Fri Feb 02, 2007 11:37 am
Posts: 4
Location: Copenhagen
Hi

When testing Albertos code example above I'm getting an error: "An exception occurred from an external component."

What am I doing wrong?

Specifically the error occours when executing the "DstFolder:=Shell32.NameSpace(ZipFileName);" statement - I'm guessing because ZipFileName points to a file and not a folder?

Code: Select all
// Vars
IntegerValue   Integer      
i   Integer      
Shell32   Automation   'Microsoft Shell Controls And Automation'.Shell   
SrcFolder   Automation   'Microsoft Shell Controls And Automation'.Folder   
DstFolder   Automation   'Microsoft Shell Controls And Automation'.Folder   
SrcItems   Automation   'Microsoft Shell Controls And Automation'.FolderItems3   
TextFile   File      
ZipFileName   Text      1024
SourceFolderName   Text      1024

//Code
ZipFileName := 'c:\test.zip';
SourceFolderName := 'c:\test';

TextFile.CREATE(ZipFileName);
TextFile.TEXTMODE(FALSE);


IntegerValue:=101010256;
TextFile.WRITE(IntegerValue);
IntegerValue:=0;
FOR i:=1 TO 9 DO
  TextFile.WRITE(IntegerValue);

TextFile.CLOSE;

if isclear(Shell32) then
  CREATE(Shell32);

SrcFolder:=Shell32.NameSpace(SourceFolderName);
DstFolder:=Shell32.NameSpace(ZipFileName);
SrcItems:=SrcFolder.Items;
DstFolder.CopyHere(SrcItems);


Besides this I'd like to know which modifications I have to make in the code in order to be able to compress (and de-compress) single files?

Thanks in advance!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 02, 2007 3:24 pm 
Offline

Joined: Tue Jul 18, 2006 12:08 pm
Posts: 19
Location: Somewhere
Country: Latvia (lv)
Which version of OS are u using? Is ZIP Folders functionality enabled?
About working with seperate files, it's the same as working with standart folders. F.e. you can define Folder.CopyHere(filename) and so on.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 03, 2007 1:35 pm 
Offline

Joined: Fri Feb 02, 2007 11:37 am
Posts: 4
Location: Copenhagen
Thanks for your reply.

I'm on WinXP.
I don't know if ZIP folders functionality is enabled or disabled - is this configurable? I was hoping to write code that would be executable on any WinXP machine.

If I understand you correct,
Code: Select all
//Var
Shell32   Automation   'Microsoft Shell Controls And Automation'.Shell   
SrcFile   Automation   'Microsoft Shell Controls And Automation'.Folder

//Code
SomeFileName := 'c:\test.txt';
SrcFile := Shell32.NameSpace(SomeFileName)

is legal?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 29 posts ]  Go to page 1, 2  Next

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum


Search for:
Jump to: