CLR: .Net / Mono / Boo / Otros CLR > VB .NET

 Guardar listbox en un txt

(1/1)

Dione:
OS cuento el problema, que será facil de resolver, pero no lo veo  :ouch: .
Tengo mi programa que hace una lista de las carpetas de un directorio y lo guarda en un listbox, hasta aquí todo bien, el problema llega cuando intento guardar el contenido del listbox en un txt.

Os pongo el código y el contenido del txt.

--- Código: vb.net --- Option Explicit On Imports System.IOPublic 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 SubEnd Class  
Contenido del txt.

--- Código: Text ---System.Windows.Forms.ListBox+ObjectCollection 
Espero que me podais ayudar.

Navegación

[0] Índice de Mensajes

Ir a la versión completa