La Web del Programador: Comunidad de Programadores
 
    Pregunta:  42603 - COMO MANIPULAR ARCHIVOS *.INI DESDE VB .NET
Autor:  Claudia Alvarado Garcia
Estoy buscando información de cómo leer, escribir y manipular un archivo *.INI desde VB .NET. Se que es con el StreamReader y StreamWriter.

  Respuesta:  Tony Medina
Codigo para manipular archivo de texto desde vb 2005 o vb.net solo tienes que cambiar la extension del archivo... Espero que te sirva...

Imports System.IO
Imports System.Text
Public Class Form1
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim objStreamReader As StreamReader
Dim strLine As String

'Pass the file path and the file name to the StreamReader constructor.
Try
objStreamReader = New StreamReader(TextBox2.Text)

'Read the first line of text.
strLine = objStreamReader.ReadLine

'Continue to read until you reach the end of the file.
ListBox1.Items.Clear()
Do While Not strLine Is Nothing

'Write the line to the List window.
ListBox1.Items.Add(strLine)

'Read the next line.
strLine = objStreamReader.ReadLine
Loop

'Close the file.
objStreamReader.Close()

Console.ReadLine()
Catch ex As Exception
ListBox1.Items.Clear()
MsgBox(ex.Message)
End Try
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Open the file.
Dim objStreamWriter As StreamWriter
Dim i As Long
objStreamWriter = New StreamWriter(TextBox2.Text, False, Encoding.Unicode)

For i = 0 To ListBox1.Items.Count - 1
objStreamWriter.WriteLine(ListBox1.Items(i).ToString)
Next

'Close the file.
objStreamWriter.Close()

End Sub

Private Sub Boton3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Boton3.Click

ListBox1.Items.Add(TextBox1.Text)
TextBox1.Text = ""
End Sub
End Class

  Respuesta:  Raul Ortega
de esa manera solo vas a poder leer archivos txt, yo queria usar archivos ini pero opte por usar archivos xml luego lo cargas en un dataset de esa manera tienes tus datos.

  Respuesta:  Edgar Molina
No se si ya encontraste lo que buscabas pero en la pagina del guille http://www.elguille.info hay una dll que te maneja todo los inis y de una manara muy facil. Si no la encunetras dime para enviartela

  Respuesta:  Van Galindo
Hola:
No entiendo muy bien tu pregunta pero quiero ayudarte; ya he manejado archivos con StreamReader y StreamWriter; recuperaba y almacenaba imagenes de una Base de datos de SqlServer; tambien he manejado archivos de texto desde disco de 31/2. Como simulando tarjetas de creidito. Si crees que puedo servirte de utilidad, escribe datallando tu problema para que pueda darte una buena respuesta ok?
Van ([email protected])

  Respuesta:  Alfredo Barrios Cruz
Hola Claudia,
Mira, si lo quieres para configurar tus aplicaciones como con vb6, deberia usuar ConfigurationSettings que guarda lo que se guardaba en un ini el el machine.config, ¿qué te parece si me escribes y te mando el código por email?, la verdad esta de volada