SoloCodigo
Programación General => Visual Basic 6.0 e inferiores => Mensaje iniciado por: martin campos quintero en Miércoles 7 de Julio de 2004, 22:37
-
Primeramente hola a todos, pues bien, lo que quiero es copiar archivos de una carpeta a otra.
Por decir si en la carpeta destino existen los archivos
cancion1.mp3
cancion2.mp3
cancion3.mp3
y en mi carpeta origen tengo x número de archivos. lo que quiero es si me pueden proporcionar un código que me copie los x número de archivos que tengo en origen a destino sin eliminar los archivos que ya están en destino.
y si no existe la carpeta origen que me mande un mensaje de que no existe
No sé como hacer eso, podrian ayudarme???
-
Ahi te va el codigo:
Private Sub Command1_Click()
PathOrigen = Dir1.Path
PathDestino = Dir2.Path
If Mid(PathOrigen, Len(PathOrigen), 1) = "\" Then
PathOrigen = Mid(PathOrigen, 1, Len(PathOrigen) - 1)
End If
If Mid(PathDestino, Len(PathDestino), 1) = "\" Then
PathDestino = Mid(PathDestino, 1, Len(PathDestino) - 1)
End If
For i = 1 To File1.ListCount
If Len(Trim(File1.List(i))) > 0 Then
ArchivoOrigen = PathOrigen & "\" & File1.List(i)
ArchivoDestino = PathDestino & "\" & File1.List(i)
msg = ArchivoOrigen & vbLf
msg = msg & ArchivoDestino
FileCopy ArchivoOrigen, ArchivoDestino
End If
Next i
End Sub
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub
Private Sub Dir2_Change()
File2.Path = Dir2.Path
End Sub
Private Sub Drive2_Change()
Dir2.Path = Drive2.Drive
End Sub
SUERTE
-
Gracias por proporcionarme el código, voy a checarlo a ver que tal me va.
Gracias por molestarte en hacerlo