1

Actually I need to compress a folder or file from local system by giving the path in javascript or ActiveXObject in IE browser and store the compressed file.

Example:

I have a folder in D drive called "sample". I need to compress the "sample" folder using javascript and store it in D drive.

zip(D:\sample) // output: sample.zip in D drive

Can anyone help me? Thanks in advance.

Anish D
  • 21
  • 2
  • `Scripting.FileSystemObject` and/or `WScript.Shell`. But, do you intend to do that in an HTML page? – manuell Jun 01 '16 at 13:03
  • @manuell I am using Scripting.FileSystemObject, Yes i have to implement in Html page. – Anish D Jun 02 '16 at 04:38
  • Use `Scripting.FileSystemObject` for creating an empty ZIP stream. Then use `WScript.Shell` (the `CopyHere` method from the `Folder` object) for zipping. BEWARE: `CopyHere` with zip destination is asynchronous. If you want to wait for the completion, you'l have to use `setTimeout` and check that the copy is done, comparing items count in the 2 folders, OR checking that you are able to open the zip folder in exclusive mode. – manuell Jun 02 '16 at 13:05
  • See: http://stackoverflow.com/questions/14699767/copy-folder-contents-to-a-created-zip-file-file-not-found-or-no-read-permissi and http://stackoverflow.com/questions/2888972/write-to-file-using-copyhere-without-using-wscript-sleep – manuell Jun 02 '16 at 13:07
  • Thank you **Manuell**, I will try the same. – Anish D Jun 08 '16 at 10:57

0 Answers0