Option Explicit On
Imports System.IO
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
For Each archivos As String In Directory.GetDirectories("c:", "*.*", SearchOption.TopDirectoryOnly)
' extraer el nombre de la carpeta de la ruta completa
archivos = archivos.Substring(archivos.LastIndexOf("") + 1).ToString
' Agregar el valor
ListBox1.Items.Add("C:" & archivos.ToString)
Next
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim oSW As New StreamWriter("C:archivo_prueba.txt")
Dim Linea = ListBox1.Items.ToString
oSW.WriteLine(Linea)
oSW.Flush()
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
End Class