You are on page 1of 1

MANEJANDO ARCHIVOS

INSERTANDO TEXTO EN UN ARCHIVO


using System;
using System.IO;
static void Main(string[] args)
{
try
{
string fileName = "temp.txt";
// esto inserta texto en un archivo existente, si el archivo no existe lo crea
StreamWriter writer = File.AppendText(fileName);
writer.WriteLine("Este es el texto adicionado.");
writer.Close();
}
catch
{
LEYENDO DESDE UN ARCHIVO DE TEXTO
using System;
using System.IO;
static void Main(string[] args)
{
string fileName = "temp.txt";
FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read);
StreamReader reader = new StreamReader(stream);
while (reader.Peek() > -1) Console.WriteLine(reader.ReadLine());
reader.Close();
}
REEMPLAZAR CARACTERES
Dim lineas As New StringBuilder
While Not myStream.EndOfStream
linea = myStream.ReadLine
Dim inicial As String = linea.Substring(0, 7)
Select Case inicial
Case "E2EDK02"
If isFactura = False Then
mFactura = linea.Substring(67, 10)
isFactura = True
End If
Case "E2EDPT2"
linea = linea.Replace("", " ")
linea = linea.Replace("", " ")
End Select
lineas.AppendLine(linea)
End While

You might also like