Filecopy with progressbar

Filecopy with progressbar

Postby Otto » Tue Nov 10, 2009 2:20 pm

Does someone please have a filecopy with a progressbar routine.

Thanks in advance
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6329
Joined: Fri Oct 07, 2005 7:07 pm

Re: Filecopy with progressbar

Postby Maurizio » Tue Nov 10, 2009 3:45 pm

Code: Select all  Expand view

#include "FWCE.ch"

//----------------------------------------------------------------------------//
function Main()
 local oWnd, oPgr ,oTimer

   DEFINE WINDOW oWnd TITLE "Progress Bars"

     DEFINE TIMER oTimer OF oWnd INTERVAL  500  ;
            ACTION StartCopy(oPgr,oWnd,oTimer)
           
      ACTIVATE TIMER oTimer

     @ 2, 8 SAY "FiveWin for Pocket PC" OF oWnd SIZE 150, 20
     @ 4, 6 PROGRESS oPgr POS 0 OF oWnd SIZE 150, 15
     @ 9, 6 BUTTON "Fine" OF oWnd SIZE 180, 30  ACTION  oWnd:End()
   ACTIVATE WINDOW oWnd


return nil

Function StartCopy(oMeter1 ,oWnd,oTimer)

   local n
   local hSource, hTarget
    Local nBufSize := 80000
   local nBytes, nFile := 0, nTotal := 0
   local nTotSize := 0
    Local cSource := "\\server\ori\risto.exe"
    Local cDest   := "risto\risto.EXE"
    Local nLen := 0
    Local lOk := .F.
    Local cBuffer := ""
    Local oIni
    Local cDir  := curdir()+ "\"
    Local cFile := cDir + "
COPY.TXT"
    Local cText := "
\\server\ori\risto.exe" + CRLF + ;
                  "
risto\risto.EXE"
    Local nX := 1
    Local nR := 1

   oTimer:DeActivate()

    IF ! file(cFile)
        MemoWrit( cFile, cText )
    ENDIF
    cText  := memoread(cFile)
    nR := mlcount(cText)
    cSource := memoline(cText,,1)
    cDest   := alltrim(cDir + memoline(cText,,2))

    cSource := alltrim(cSource)
    IF ! file(cSource)
      oTimer:Activate()
        Return nil
    ENDIF

      hTarget = FCreate( cDest )
        IF hTarget == - 1
         oTimer:Activate()
            return nil
        ENDIF
      cBuffer := Space( nBufSize )

      hSource = FOpen( cSource )
        IF hSource == -1
         oTimer:Activate()
            return nil
        ENDIF

      nLen :=  FSeek( hSource, 0, 2 ) / nBufSize
      FSeek( hSource, 0, 0 )
        oMeter1:SetRange( 0, nLen)

      nFile := 0
      while ( nBytes := FRead( hSource, @cBuffer, nBufSize ) ) > 0
          FWrite( hTarget, cBuffer, nBytes )
          oMeter1:nPosition ++
             oMeter1:Refresh()
            lOk := .T.
      end
      FClose( hSource )
      FClose( hTarget )

      IF lOk
         IF FERASE(cSource) == - 1
              MsgInfo("
Non cancellato")
         ELSE
              // MsgInfo("
File copiato")
         ENDIF
      ENDIF


     oMeter1:nPosition := 0
      oMeter1:Refresh()

     oTimer:Activate()

return nil
User avatar
Maurizio
 
Posts: 824
Joined: Mon Oct 10, 2005 1:29 pm

Re: Filecopy with progressbar

Postby Otto » Tue Nov 10, 2009 8:08 pm

Maurizio, thank you very much.
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6329
Joined: Fri Oct 07, 2005 7:07 pm


Return to FiveWin for Pocket PC

Who is online

Users browsing this forum: No registered users and 22 guests

cron