i am making a software in vb6 i wnat that the file should be zipped automatically

i have coded

Dim retval
retval = Shell("c:\itchain\pkzip.exe c:\itchain\ c:\itchain\itchain.mdb", vbHide)

the problem here is that if the person instals in other directory than then the c:\pkzip and the c:\itchain\itchain.mdb is not found

can app.path be used

please help fast

Who is Participating?
autConnect With a Mentor Commented:
Instead of using PKZip, you should use the InfoZip library to zip files from within the program.
Check it out here:
You'll find a DLL file, as well as a VB demonstration project that shows you how you should implement it in your project.

This way, you don't have to worry about path problems. Also, the library supports long file names (all older version of PKZip do not). It will be faster too...
Why not use code like this..

Dim retval
retval = Shell(sAddDirSep(App.Path) & "pkzip.exe", sAddDirSep(App.Path) & ""
sAddDirSep(App.Path) & "itchain.mdb", vbHide)

or perhaps even better...

Dim retval
retval = Shell("""" & sAddDirSep(App.Path) & "pkzip.exe""", """" & sAddDirSep(App.Path) & """"
"""" & sAddDirSep(App.Path) & "itchain.mdb""", vbHide)

These codes uses this small function

  Function sAddDirSep(Rad As String) As String

    sAddDirSep = IIf(Right$(Rad, 1) = "\", Rad, Rad & "\")
  End Function
Aut: do u know when it bugs out? I tried those libraries earlier but with some files it would not compress/decompress, I didn't actually bother testing it that much (I guess there's something wrong with certain filenames perhaps..) but perhaps you have tried it "a lot" and know what the problem might be?
VbMaster: the older version of the DLL had problems with VB (so they said when I mailed them). The newly-released version is stable, and I used it in a program I wrote with no problems at all
All Courses

From novice to tech pro — start learning today.