INCLUIR SUB-PASTAS NO BACKUP

RICATOM 01/07/2010 11:21:21
#346244
Bom dia colegas

Estou usando a dll AUNZIP32 para fazer backup, mas agora preciso fazer backup também das sub-pastas, mas não estou conseguindo

Estou usando o modulo

[c] Option Explicit

Declare Function addZIP Lib [Ô]azip32.dll[Ô] () As Integer
Declare Function addZIP_Abort Lib [Ô]azip32.dll[Ô] (ByVal bFlag As Integer) As Integer
Declare Function addZIP_ArchiveName Lib [Ô]azip32.dll[Ô] (ByVal lpStr As String) As Integer
Declare Function addZIP_BuildSFX Lib [Ô]azip32.dll[Ô] (ByVal iFlag As Integer) As Integer
Declare Function addZIP_ClearAttributes Lib [Ô]azip32.dll[Ô] (ByVal Int16 As Integer) As Integer
Declare Function addZIP_Comment Lib [Ô]azip32.dll[Ô] (ByVal lpStr As String) As Integer
Declare Function addZIP_Delete Lib [Ô]azip32.dll[Ô] (ByVal Int16 As Integer) As Integer
Declare Function addZIP_DeleteComment Lib [Ô]azip32.dll[Ô] (ByVal Int16 As Integer) As Integer
Declare Function addZIP_DisplayComment Lib [Ô]azip32.dll[Ô] (ByVal Int16 As Integer) As Integer
Declare Function addZIP_Encrypt Lib [Ô]azip32.dll[Ô] (ByVal lpStr As String) As Integer
Declare Function addZIP_Exclude Lib [Ô]azip32.dll[Ô] (ByVal lpStr As String) As Integer
Declare Function addZIP_ExcludeListFile Lib [Ô]azip32.dll[Ô] (ByVal lpStr As String) As Integer
Declare Function addZIP_GetLastError Lib [Ô]azip32.dll[Ô] () As Integer
Declare Function addZIP_GetLastWarning Lib [Ô]azip32.dll[Ô] () As Integer
Declare Function addZIP_Include Lib [Ô]azip32.dll[Ô] (ByVal lpStr As String) As Integer
Declare Function addZIP_IncludeArchive Lib [Ô]azip32.dll[Ô] (ByVal iFlag As Integer) As Integer
Declare Function addZIP_IncludeDirectoryEntries Lib [Ô]azip32.dll[Ô] (ByVal flag As Integer) As Integer
Declare Function addZIP_IncludeFilesNewer Lib [Ô]azip32.dll[Ô] (ByVal DateVal As String) As Integer
Declare Function addZIP_IncludeFilesOlder Lib [Ô]azip32.dll[Ô] (ByVal DateVal As String) As Integer
Declare Function addZIP_IncludeHidden Lib [Ô]azip32.dll[Ô] (ByVal iFlag As Integer) As Integer
Declare Function addZIP_IncludeListFile Lib [Ô]azip32.dll[Ô] (ByVal lpStr As String) As Integer
Declare Function addZIP_IncludeReadOnly Lib [Ô]azip32.dll[Ô] (ByVal iFlag As Integer) As Integer
Declare Function addZIP_IncludeSystem Lib [Ô]azip32.dll[Ô] (ByVal iFlag As Integer) As Integer
Declare Sub addZIP_Initialise Lib [Ô]azip32.dll[Ô] ()
Declare Function addZIP_InstallCallback Lib [Ô]azip32.dll[Ô] (ByVal cbFunction As Long) As Integer
Declare Function addZIP_Overwrite Lib [Ô]azip32.dll[Ô] (ByVal Int16 As Integer) As Integer
Declare Function addZIP_Recurse Lib [Ô]azip32.dll[Ô] (ByVal Int16 As Integer) As Integer
Declare Function addZIP_Register Lib [Ô]azip32.dll[Ô] (ByVal lpStr As String, ByVal Uint32 As Long) As Integer
Declare Function addZIP_SaveAttributes Lib [Ô]azip32.dll[Ô] (ByVal Int16 As Integer) As Integer
Declare Function addZIP_SaveRelativeTo Lib [Ô]azip32.dll[Ô] (ByVal szPath As String) As Integer
Declare Function addZIP_SaveStructure Lib [Ô]azip32.dll[Ô] (ByVal Int16 As Integer) As Integer
Declare Function addZIP_SetArchiveDate Lib [Ô]azip32.dll[Ô] (ByVal Int16 As Integer) As Integer
Declare Function addZIP_SetCompressionLevel Lib [Ô]azip32.dll[Ô] (ByVal Int16 As Integer) As Integer
Declare Function addZIP_SetParentWindowHandle Lib [Ô]azip32.dll[Ô] (ByVal Hwnd As Long) As Integer
Declare Function addZIP_SetTempDrive Lib [Ô]azip32.dll[Ô] (ByVal lpStr As String) As Integer
Declare Function addZIP_SetWindowHandle Lib [Ô]azip32.dll[Ô] (ByVal Hwnd As Long) As Integer
Declare Function addZIP_Span Lib [Ô]azip32.dll[Ô] (ByVal Int16 As Integer) As Integer
Declare Function addZIP_Store Lib [Ô]azip32.dll[Ô] (ByVal lpStr As String) As Integer
Declare Function addZIP_UseLFN Lib [Ô]azip32.dll[Ô] (ByVal Int16 As Integer) As Integer
Declare Function addZIP_View Lib [Ô]azip32.dll[Ô] (ByVal Int16 As Integer) As Integer

Declare Function addUNZIP Lib [Ô]aunzip32.dll[Ô] () As Long
Declare Function addUNZIP_Abort Lib [Ô]aunzip32.dll[Ô] (ByVal iFlag As Integer) As Integer
Declare Function addUNZIP_ArchiveName Lib [Ô]aunzip32.dll[Ô] (ByVal FileName As String) As Integer
Declare Function addUNZIP_Decrypt Lib [Ô]aunzip32.dll[Ô] (ByVal cPassword As String) As Integer
Declare Function addUNZIP_DisplayComment Lib [Ô]aunzip32.dll[Ô] (ByVal bFlag As Integer) As Integer
Declare Function addUNZIP_Exclude Lib [Ô]aunzip32.dll[Ô] (ByVal files As String) As Integer
Declare Function addUNZIP_ExcludeListFile Lib [Ô]aunzip32.dll[Ô] (ByVal cFile As String) As Integer
Declare Function addUNZIP_ExtractTo Lib [Ô]aunzip32.dll[Ô] (ByVal cPath As String) As Integer
Declare Function addUNZIP_Freshen Lib [Ô]aunzip32.dll[Ô] (ByVal iFlag As Integer) As Integer
Declare Function addUNZIP_GetLastError Lib [Ô]aunzip32.dll[Ô] () As Integer
Declare Function addUNZIP_GetLastWarning Lib [Ô]aunzip32.dll[Ô] () As Integer
Declare Function addUNZIP_Include Lib [Ô]aunzip32.dll[Ô] (ByVal files As String) As Integer
Declare Function addUNZIP_IncludeListFile Lib [Ô]aunzip32.dll[Ô] (ByVal cFile As String) As Integer
Declare Sub addUNZIP_Initialise Lib [Ô]aunzip32.dll[Ô] ()
Declare Function addUNZIP_InstallCallback Lib [Ô]aunzip32.dll[Ô] (ByVal fn As Long) As Integer
Declare Function addUNZIP_Overwrite Lib [Ô]aunzip32.dll[Ô] (ByVal iFlag As Integer) As Integer
Declare Function addUNZIP_Register Lib [Ô]aunzip32.dll[Ô] (ByVal cName As String, ByVal iNumber As Long) As Integer
Declare Function addUNZIP_ResetDefaults Lib [Ô]aunzip32.dll[Ô] ()
Declare Function addUNZIP_RestoreAttributes Lib [Ô]aunzip32.dll[Ô] (ByVal iFlag As Integer) As Integer
Declare Function addUNZIP_RestoreStructure Lib [Ô]aunzip32.dll[Ô] (ByVal iFlag As Integer) As Integer
Declare Function addUNZIP_SetParentWindowHandle Lib [Ô]aunzip32.dll[Ô] (ByVal Hwnd As Long) As Integer
Declare Function addUNZIP_SetWindowHandle Lib [Ô]aunzip32.dll[Ô] (ByVal Hwnd As Long) As Integer
Declare Function addUNZIP_Test Lib [Ô]aunzip32.dll[Ô] (ByVal iFlag As Integer) As Integer
Declare Function addUNZIP_ToMemory Lib [Ô]aunzip32.dll[Ô] (ByVal lpStr As String, ByVal Uint32 As Long) As Integer
Declare Function addUNZIP_Update Lib [Ô]aunzip32.dll[Ô] (ByVal iFlag As Integer) As Integer
Declare Function addUNZIP_View Lib [Ô]aunzip32.dll[Ô] (ByVal bFlag As Integer) As Integer

Global Const azCOMPRESSION_MAXIMUM = &H3
Global Const azCOMPRESSION_MINIMUM = &H1
Global Const azCOMPRESSION_NONE = &H0
Global Const azCOMPRESSION_NORMAL = &H2

Global Const azSTRUCTURE_ABSOLUTE = &H2
Global Const azSTRUCTURE_NONE = &H0
Global Const azSTRUCTURE_RELATIVE = &H1

Global Const azOVERWRITE_ALL = &HB
Global Const azOVERWRITE_NONE = &HC
Global Const azOVERWRITE_QUERY = &HA

Global Const DATE_NEWEST = &H3
Global Const DATE_OLDEST = &H2
Global Const DATE_ORIGINAL = &H0
Global Const DATE_TODAY = &H1

Global Const azNEVER = &H0
Global Const azALWAYS = &HFF
Global Const azYES = &H1

Global Const azATTR_NONE = 0
Global Const azATTR_READONLY = 1
Global Const azATTR_HIDDEN = 2
Global Const azATTR_SYSTEM = 4
Global Const azATTR_ARCHIVE = 32
Global Const azATTR_ALL = 39

Global Const azLIBRARY_ADDZIP = 0
Global Const azLIBRARY_ADDUNZIP = 1

Global Const AM_SEARCHING = &HA
Global Const AM_ZIPCOMMENT = &HB
Global Const AM_ZIPPING = &HC
Global Const AM_ZIPPED = &HD
Global Const AM_UNZIPPING = &HE
Global Const AM_UNZIPPED = &HF
Global Const AM_TESTING = &H10
Global Const AM_TESTED = &H11
Global Const AM_DELETING = &H12
Global Const AM_DELETED = &H13
Global Const AM_DISKCHANGE = &H14
Global Const AM_VIEW = &H15
Global Const AM_ERROR = &H16
Global Const AM_WARNING = &H17
Global Const AM_QUERYOVERWRITE = &H18
Global Const AM_COPYING = &H19
Global Const AM_COPIED = &H1A
Global Const AM_ABORT = &HFF

Global Const azFT_ENCRYPTED = &H1
Global Const azFT_NOT_ENCRYPTED = &H0

Global Const azFT_BINARY = &H1
Global Const azFT_TEXT = &H0

Global Const azCM_DEFLATED_FAST = &H52
Global Const azCM_DEFLATED_MAXIMUM = &H51
Global Const azCM_DEFLATED_NORMAL = &H50
Global Const azCM_DEFLATED_SUPERFAST = &H53
Global Const azCM_IMPLODED = &H3C
Global Const azCM_NONE = &H0
Global Const azCM_REDUCED_1 = &H14
Global Const azCM_REDUCED_2 = &H1E
Global Const azCM_REDUCED_3 = &H28
Global Const azCM_REDUCED_4 = &H32
Global Const azCM_SHRUNK = &HA
Global Const azCM_TOKENISED = &H46
Global Const azCM_UNKNOWN = &HFF

Global Const azOW_NO = &H2
Global Const azOW_NO_TO_ALL = &H3
Global Const azOW_YES = &H0
Global Const azOW_YES_TO_ALL = &H1

Public Z As Integer

Function GetAction(cfrom As String) As Integer

GetAction = Val(GetPiece(cfrom, [Ô]|[Ô], 2))

End Function

Function GetFileCompressedSize(cfrom As String) As Long

GetFileCompressedSize = Val(GetPiece(cfrom, [Ô]|[Ô], 6))

End Function

Function GetFileCompressionRatio(cfrom As String) As Integer

GetFileCompressionRatio = Val(GetPiece(cfrom, [Ô]|[Ô], 7))

End Function

Function GetFileName(cfrom As String) As String

GetFileName = GetPiece(cfrom, [Ô]|[Ô], 4)

End Function

Function GetFileOriginalSize(cfrom As String) As Long

GetFileOriginalSize = Val(GetPiece(cfrom, [Ô]|[Ô], 5))

End Function

Function GetPercentComplete(cfrom As String) As Integer

GetPercentComplete = Val(GetPiece(cfrom, [Ô]|[Ô], 7))

End Function

Function GetPiece(from As String, delim As String, Index As Integer) As String

Dim Temp$
Dim Count As Integer
Dim where As Integer

Temp$ = from & delim
where = InStr(Temp$, delim)
Count = 0
Do While (where > 0)
Count = Count + 1
If (Count = Index) Then
GetPiece = Left$(Temp$, where - 1)
Exit Function
End If
Temp$ = Right$(Temp$, Len(Temp$) - where)
where = InStr(Temp$, delim)
Loop
If (Count = 0) Then
GetPiece = from
Else
GetPiece = [Ô][Ô]
End If
End Function

Sub Compacta(cArqCompactado As String, cArq As String)

Z = addZIP_SetCompressionLevel(azCOMPRESSION_MAXIMUM)
[ô]Z = addZIP_SaveStructure(SalvaDir) [ô]StoreFullPathName - azSTRUCTURE_ABSOLUTE
Z = addZIP_Include(cArq)
Z = addZIP_ArchiveName(cArqCompactado)
[ô]Z = addZIP_Delete(DeletarOrig)
Z = addZIP()
End Sub

Sub DesCompacta(cArqCompactado As String, cNomeArq As String, ExtrairPara As String, MontaDir As Boolean)

Z = addUNZIP_Overwrite(azOVERWRITE_ALL)
Z = addUNZIP_ArchiveName(cArqCompactado)
Z = addUNZIP_Include(cNomeArq)
Z = ad
RICATOM 02/07/2010 13:13:02
#346390
Alguém?
JSFF77 02/07/2010 14:20:36
#346395
Boa tarde.

Amigo,

Consegui resolver esse problema alterando o seguite na rotina Compacta():


Sub Compacta(cArqCompactado As String, cArq1 As String, cArq2 As String)
[ô]Inicializa as bibliotecas do addZIP
addZIP_Initialise
addUNZIP_Initialise

[ô]Compacta um ou mais arquivos no formato WinZip
z = addZIP_SetCompressionLevel(azCOMPRESSION_MAXIMUM)
[ô]z = addZIP_SaveStructure(azSTRUCTURE_ABSOLUTE) [ô]StoreFullPathName - azSTRUCTURE_ABSOLUTE

z = addZIP_ArchiveName(cArqCompactado)
z = addZIP_Include(cArq1)
z = addZIP()

z = addZIP_ArchiveName(cArqCompactado)
z = addZIP_Include(cArq2)
z = addZIP()
End Sub


e chamando-a assim:

Compacta [Ô]Arquivo.zip[Ô], [Ô]C:\PASTA1\*.*[Ô], [Ô]C:\PASTA1\SUBPASTA1\*.*[Ô]


é isso. Se os demais amigos encontrarem outra solução, postem aí!

Até mais.


JSFF77
RICATOM 02/07/2010 16:04:47
#346402
JSFF77 obrigado pela resposta, mas na verdade são várias subpastas com subpastas dentro delas

Deve ter algum comando que inclua as subpastas de forma automatica
RICATOM 05/07/2010 13:45:01
#346539
Ninguém???
RICATOM 05/07/2010 15:29:20
#346555
Citação:

LVFIOROT escreveu: VC PODE CRIAR UMA ROTINA TIPO UMA RECURSIVA PARA VARRER TODOS OS DIRETORIOS E ARQUIVOS



Poderia ser mais claro?

Obs: preciso manter a estrutura das pastas e subpastas dentro do bkp.
RICATOM 05/07/2010 17:43:45
#346571
LVFIOROT, ficou perfeito, obrigado

Tópico encerrado , respostas não são mais permitidas