Jump to content

Progress bar


Go to solution Solved by Nine,

Recommended Posts

I made an exe to save the AppData directory it works quite well I would like to add a progress bar but I am unable to, I don't have the level can anyone help me if not is not too complicated for you of course
Thanks a lot


#include <FileConstants.au3>
#include <File.au3>
#include <Date.au3>


$date = @MDAY & "-" & @MON


Local $AppDataPath = @AppDataDir
Local $LocalAppDataPath = @LocalAppDataDir


Local $BackupPath = "D:\" & $date & '.\Backup'
Local $Search = FileFindFirstFile($AppDataPath & "\*.*")


FileClose($Search)

; Copie récursive des fichiers et dossiers
Func CopyFolder($SourcePath, $DestPath)
    Local $Search = FileFindFirstFile($SourcePath & "\*.*")
    If $Search = -1 Then Return

    Local $CopiedFiles = 0

    While 1
        Local $File = FileFindNextFile($Search)
        If @error Then ExitLoop

        If Not @extended Then
            ; Fichier trouvé, copie vers le répertoire de sauvegarde
            FileCopy($SourcePath & "\" & $File, $DestPath & "\" & $File, $FC_OVERWRITE)
            $CopiedFiles += 1

        ElseIf StringInStr(FileGetAttrib($SourcePath & "\" & $File), "D") Then
            ; Dossier trouvé, récursion
            If $File <> "." And $File <> ".." Then
                DirCreate($DestPath & "\" & $File)
                CopyFolder($SourcePath & "\" & $File, $DestPath & "\" & $File)
            EndIf
        EndIf

    WEnd

    FileClose($Search)
EndFunc


; Début de la copie des répertoires AppData, Local et Roaming
CopyFolder($AppDataPath, $BackupPath &"\AppData\Roaming")
CopyFolder($LocalAppDataPath, $BackupPath &"\AppData\Local")


; Affichage du message à la fin de la copie
MsgBox(64, "Copie terminée", "La sauvegarde des répertoires Roaming , Local est terminée.")

 

Link to comment
Share on other sites

  • Solution
Posted (edited)

Salutations @teodoric666.  Here how I would do it :

#include <File.au3>

Local $sDate = @MDAY & "-" & @MON
Local $sSource = "C:\Users\" & @UserName & "\AppData\"
Local $sBackupPath = "D:\" & $sDate & '\Backup\'

Local $aList = _FileListToArrayRec($sSource, "*||LocalLow", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_RELPATH)
ProgressOn("Backup " & $sDate, "0% completed")
Local $nProgress, $nPrec

For $i = 1 To $aList[0]
  FileCopy($sSource & $aList[$i], $sBackupPath & $aList[$i], $FC_OVERWRITE + $FC_CREATEPATH)
  $nProgress = Int($i / $aList[0] * 100)
  If $nProgress = $nPrec Then ContinueLoop
  ProgressSet($nProgress, $nProgress & "% completed")
  $nPrec = $nProgress
Next

ProgressSet(100, "Backup completed")
Sleep(2000)
ProgressOff()

 

Edited by Nine
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...