Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

combining pkzip and vb 3

Status
Not open for further replies.

Wilber007

Programmer
Aug 15, 2001
13
GB
Hi guys, happy new year to u all!! :)

using a batch file, i have created a txt file. now i want to do 2 things to this file, first i want to return the size of it, there must be some function call to allow me to do this. secondly i want to compress this file using 'pkzip' and then return the new size of it.

if anybody knows a) what the call is for file_size and b) how do i pass a txt.file into pkzip so that it get compressed

i would be most appreciative!!

thanks all,

Wilber
 

First part is easy. Check out the FileLen function in VB. The second part will require you to know what the command line parameters for PKZip are and to use the shell function which can also be found in VB's help.

Good Luck

 
Dont know about PKZip but if you are using WinZip then you should get a copy of WinZip commandline add-on (wzcline.exe) I think its free for personal use and comes with plenty of help and examples. You will still need to use the Shell function to execute it.

As per vb5prgrmr suggestion use FileLen to get the size of files.

Hope this is if help

cjw
 
it will look like...

dim before as long
dim after as long
before = FileLen("mytext.txt")
shell "pkzip mytext.zip mytext.txt"
'be careful here... you might end up trying to get the file size before the file is created...
after = FileLen("mytext.zip")

there is some function you can use to wait for the shell to finish... I think it is something like AppActivate

Syntax
Code:
AppActivate title as string [, wait as boolean]

Use:
'AppActivate can also use the return value of the Shell function.
MyAppID = Shell("C:\WORD\WINWORD.EXE", 1) 'Run Microsoft Word.
AppActivate MyAppID 'Activate Microsoft Word.

So try this...

dim before as long
dim after as long
before = FileLen("mytext.txt")
myPrg = shell "pkzip mytext.zip mytext.txt"
AppActivate myPrg, True
file size before the file is created...[/b]
after = FileLen("mytext.zip")

Sometimes... the BASIC things in life are the best...
cheers.gif

or at least the most fun ;-)
-Josh Stribling
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top