Ver Mensaje Individual
  #6 (permalink)  
Antiguo 19/08/2011, 11:55
Avatar de Aquaventus
Aquaventus
 
Fecha de Ingreso: junio-2010
Ubicación: Lima-Peru , En el alba de la naturaleza
Mensajes: 2.105
Antigüedad: 14 años, 7 meses
Puntos: 267
Respuesta: Borrar caracteres de .txt

Podrias hacer esto :

Código vb:
Ver original
  1. Dim Fs As FileStream = New FileStream("\\Dell\compartido\agosto\1MRM0412304Y9 072011.txt", FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite)
  2. Dim sw As New StreamWriter(Fs)
  3. Dim sr As New StreamReader(Fs)
  4. Dim str As String
  5. Dim contador As Integer
  6. Dim total as Integer
  7. Dim nuevaCadena As String = String.Empty
  8. Dim a As Char()
  9. str = sr.ReadToEnd()
  10. a = str.ToCharArray
  11.  
  12. total = str.Length() - 1
  13.  
  14. For i as Integer = 0 To  total
  15.  
  16. If a(i).ToString.Equals("|") Then
  17. contador = contador + 1
  18. End If
  19.  
  20. If contador <= 10 Then
  21. nuevaCadena = nuevaCadena & a(i).ToString
  22. End If
  23.  
  24. Next
  25.  
  26. sw.Write(nuevaCadena)
  27. sw.Flush()
  28. MessageBox.Show("OK")
  29. sw.Close()
  30. Fs.Close()

Pruebalo y me comentas. Saludos!.
__________________
Internet es tener todo el conocimiento global a tu disposición.
Desarrollo de Software - Ejemplos .Net