It is currently Sat Feb 29, 2020 4:32 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Include and extract Zip
PostPosted: Sat May 19, 2007 12:58 pm 
Offline
Enthusiast
Enthusiast

Joined: Wed Apr 18, 2007 9:27 pm
Posts: 195
Can some give me a code on how to include a zip file and extract it on a button click?

Thanks in advance

Heres my code:

Code:
Enumeration
  #Window_0
EndEnumeration

Enumeration
  #Button_0
EndEnumeration

DataSection
Zip0:
  IncludeBinary "C:\1.zip"
EndDataSection

Procedure Open_Window_0(Title.s)
  If OpenWindow(#Window_0, 299, 267, 100, 100, Title, #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

    If CreateGadgetList(WindowID(#Window_0))
      ButtonGadget(#Button_0, 5, 5, 80, 22, "&Extract", #PB_Button_Default)
    EndIf
  EndIf
EndProcedure

    Open_Window_0("Zip Extract")
   
    Repeat
    Event = WindowEvent()
    GadgetID = EventGadget()
         
    If Event = #PB_Event_Gadget
        If GadgetID = #Button_0
              PureZIP_ExtractFiles(Zip0, "*.*", "C:\1\", #True)
        EndIf
 
    EndIf
         
    Until Event = #PB_Event_CloseWindow


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat May 19, 2007 3:44 pm 
Offline
PureBasic Bullfrog
PureBasic Bullfrog
User avatar

Joined: Wed Jul 06, 2005 5:42 am
Posts: 8027
Location: Fort Nelson, BC, Canada
This is working here:
Code:
Enumeration
  #Window_0
EndEnumeration

Enumeration
  #Button_0
EndEnumeration

DataSection
Zip0:
  IncludeBinary "d:\ziptest\ziptest.zip"
zipend:
EndDataSection

Procedure Open_Window_0(Title.s)
  If OpenWindow(#Window_0, 299, 267, 100, 100, Title, #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

    If CreateGadgetList(WindowID(#Window_0))
      ButtonGadget(#Button_0, 5, 5, 80, 22, "&Extract", #PB_Button_Default)
    EndIf
  EndIf
EndProcedure

    Open_Window_0("Zip Extract")
   
    Repeat
    Event = WaitWindowEvent()
    GadgetID = EventGadget()
         
    If Event = #PB_Event_Gadget
        If GadgetID = #Button_0
          If CreateFile(0, "c:\ziptest.zip")
            WriteData(0, ?zip0, ?zipend-?zip0)
            CloseFile(0)
            If PureZIP_ExtractFile("c:\ziptest.zip", 1, "c:\", #True)
              MessageRequester("Status:","Zip extraction succeeded!")
            Else
              MessageRequester("Status:","Zip extraction failed!")
            EndIf
            DeleteFile("c:\ziptest.zip")
          EndIf
        EndIf
 
    EndIf
         
    Until Event = #PB_Event_CloseWindow

_________________
Veni, vidi, vici.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat May 19, 2007 6:18 pm 
Offline
Enthusiast
Enthusiast

Joined: Wed Apr 18, 2007 9:27 pm
Posts: 195
Thanks!


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 11 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

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye