Salve ragazzi....avrei qlcs da chiedere...ho realizzato un tool per fare il backup...ma mi sono accorto con mia amarezza..che qnd copio il file seppure me li copia mi da dimensione 0...vi posto il codice grazie per l'aiuto
Codice in vb6
Function CopiaFile(origine As String, destinazione As String) As Long
Const BufferSize = 1024 'settaggio del buffer
Static Buf$
Dim BTest!, FSize!
Dim Chunk%, F1%, F2%
LunghezzaFileDestinazione = 0
Open origine For Binary As #1 ' Apre il file.
Flunghezza = LOF(1) ' Ottiene la lunghezza del file.
Open destinazione For Binary As #2 ' Apre il file.
BTest = Flunghezza - LOF(2)
Do
If BTest < BufferSize Then
Chunk = BTest
Else
Chunk = BufferSize
End If
Buf = String(Chunk, " ")
Get 1, , Buf
Put 2, , Buf
BTest = Flunghezza - LOF(2)
Loop Until BTest = 0
Close 1 'closes the source file
Close 2 'closes the destination file
End Function
Private Sub cmdAvviaCopia_Click()
Dim e As String
Dim sTempFile() As String
Dim sTemp() As String
Dim sFile As String
Dim sFileDest As String
Dim sMsg As String
Dim I As Integer
Dir1.Enabled = False
File1.Enabled = False
For I = 0 To listFile.ListCount - 1
PB1.Max = listFile.ListCount
PB1.Min = 0
lblOrigine.Caption = ""
lblDestinazione.Caption = ""
If listFile.Selected(I) = True Then
lavoro = Text1.Text
files = Dir1.Path & "\" & listFile.List(I)
sFile = listFile.List(I)
e = CopiaFile(sFile, Text1 & "\" & sFile)
lblOrigine.Caption = " " & Dir1.Path & "\" & sFile
lblDestinazione.Caption = " " & Text1 & "\" & sFile
End If
lblFile.Caption = " " & sFile
PB1.Value = PB1.Min + 1
Next I
MsgBox "La Copia dei file selezionati è stata effettuata con successo", vbInformation
Dir1.Enabled = True
File1.Enabled = True
End Sub
Ecco perkè pur copiandomi il file mi da dimensione 0 byte?
Ultima modifica effettuata da Nesher il 22/09/2009 alle 15:34 |