Buenas tardes, escribo este post porque necesito algo de ayuda para realizar un código, soy algo novato por lo que puedo decir cosas "raras".
Les comento, he hecho una aplicación para copiar los nombres de los archivos de el directorio deseado.
Ahora lo que quiero hacer y no lo consigo es lo siguiente:
Necesito eliminar archivos de un determinado tamaño fijado por un textbox al lado de un commandbuttom, estos archivos quiero que sean los que están en la carpeta elegida y que aparece en el filelistbox.
¿Alguna idea por favor?
Muchísimas gracias por todo y espero no inflingir las normas del foro, si es así lo siento mucho.
He utilizado el codigo http://foro.elhacker.net/programacion_visual_basic/eliminar_archivo_con_un_command_desde_el_filelistbox-t268759.0.html
y me sirve perfectamente solo que en vez de eliminar archivo por archivo necesito que un textbox fije el tamaño de TODOS los archivos a eliminar pero que sean siempre INFERIOR el tamaño al del textbox.
HOLA!!!
Mmm, yo lo haria con :
FileLen("RUTA_DEL_ARCHIVO")
Osea, recorres todos los archivos del FileListBox y te fijas si su FileLen es Mayor o Menor que el numero del TextBox.
GRACIAS POR LEER!!!
No entiendo a que te refieres jajaja pero gracias ahora sigo probando
HOLA!!!
Si no me equivoco el FileListBox muestra todos los archivos que estan en una carpeta (Suponiendo que no hay filtros) bueno la RUTA de la carpeta la tenes, sino el FileListBox no funcionaria. Lo que tenes que hacer es concatenar (Unir) la ruta de la carpeta con el nombre de cada archivo para poder obtener la RUTA_DEL_ARCHIVO (de cada uno).
GRACIAS POR LEER!!!
No se si nos entendemos bien, jajaja,
Private Sub Command1_Click()
Dim x
Text1.Text = ""
For x = 0 To File1.ListCount - 1
Text1.Text = Text1.Text & File1.List(x) & vbCrLf
Next
End Sub
Private Sub Command2_Click()
Dim i As Integer
Dim Ruta As String
Dim t As Single
DoEvents
t = Timer
For i = 0 To File1.ListCount - 1
If File1.Selected(i) = True Then
If MsgBox("Estas seguro de eliminar " + File1.FileName + "?", vbQuestion + vbYesNo, "Eliminar Archivo") = vbYes Then
If Right(File1.Path, 1) <> "\" Then
Ruta = File1.Path & "\" & File1.FileName
Else
Ruta = File1.Path & File1.FileName
SetAttr Ruta, vbNormal
Kill Ruta
File1.Selected(i) = False
File1.Refresh
Exit For
End If
End If
End If
Next i
Label2.Caption = "Tiempo de eliminación en segundos = " & Format(Timer - t, "0.00")
End Sub
Private Sub Command3_Click()
Form2.Show
End Sub
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub
Private Sub Drive1_Change()
On Local Error Resume Next
Dir1.Path = Drive1.Drive
Select Case Err.Number
Case 0
'no hay error
Case 68
MsgBox "Error número " & Err.Number & vbCrLf & Err.Description, vbCritical + vbOKOnly, "Inserte disco"
Case Else
MsgBox Err.Number & vbCrLf & Err.Description, vbCritical + vbOKOnly, "Error"
End Select
On Local Error GoTo 0
End Sub
Private Sub File1_Click()
If Right(File1.Path, 1) <> "\" Then
Text1.Text = File1.FileName
Else
Text1.Text = File1.FileName
End If
End Sub
Private Sub Form_Load()
Dir1.Path = "c:\"
End Sub
Ese es mi codigo.