
02/02/2010, 12:16
|
| | Fecha de Ingreso: septiembre-2009
Mensajes: 135
Antigüedad: 15 años, 6 meses Puntos: 0 | |
Respuesta: Leer y grabar archivos txt Gracias por las lecturas a mi pregunta pos ya investigando un poco aqui esta el codigo resuelto ojala alguien le ayude:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd_carga.Click
Dim VRuta As String
Dim objStreamWriter As StreamWriter
Dim sLine As String = ""
Dim arrText As New ArrayList
Dim j As Integer
Dim VDelimitador As String
Dim result As DialogResult = OpenFileDialog1.ShowDialog()
Dim VBanco, VMes As String
VBanco = Me.cmb_banco.SelectedItem
VMes = Month(Now) & "-" & Year(Now)
If VBanco <> "Seleccione" Then
Select Case VBanco
Case "G"
VBanco = "B1L"
Case "A"
VBanco = "B2S"
Case "P"
VBanco = "b3"
Case Else
lblerror.Visible = True
lblerror.Text = "Seleccione el Banco"
Exit Sub
End Select
If result = DialogResult.OK Then
VRuta = VRuta & OpenFileDialog1.FileName
TextBox1.Text = VRuta
Else
Me.lblerror.Visible = True
Me.lblerror.Text = "Debe ingresar una ruta existente"
Exit Sub
End If
Dim objReader As New StreamReader(VRuta)
VDelimitador = Chr(9) 'Separador Tab
Do
sLine = objReader.ReadLine()
If Not sLine Is Nothing Then
arrText.Add(sLine)
End If
Loop Until sLine Is Nothing
objReader.Close()
objStreamWriter = New StreamWriter("J:\" & VBanco & "-" & VMes & ".txt")
Me.txtLog.Visible = True
j = 0
For Each sLine In arrText
'Console.WriteLine(sLine)
objStreamWriter.WriteLine(VBanco & VDelimitador & arrText(j))
Me.txtLog.Text = arrText(j)
j = j + 1
Next
'Console.ReadLine()
objStreamWriter.Close()
Else
lblerror.Visible = True
lblerror.Text = "Seleccione el Banco"
Exit Sub
End If
End Sub |