Programación c# archivos
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;//Libreria para manipular File
namespace Archivos
{
class Program
{
staticvoid Main(string[] args)
{
EscribirArchivoTxt();
CrearArchivoEscribir();
LeerBufferedStream();
LeerArchivoTxt();InsertarTxtArchivo();
LeerArchivoBin();
EscribiendoArchivoBin();
Console.Read();
}
/// <summary>
/// Como se comenta un método!/// </summary>
public static void LeerBufferedStream()
{
string pathr = @"C:\Users\j.cruz\Archivo.xml";//OBTENGO ELPATH
Stream instream =File.OpenRead(pathr);//OBTENGO EL OBJETO
// crear buffer para abrir stream
BufferedStream bufin = new BufferedStream(instream);//LLAMO A LA CLASE Y CREO CONSTRUCTORbyte[] bytes = new byte[128];//CREA ARREGLO TIPO BYTE DE 128 BYTES (paquetes para ir mandando el archivo)
// leer los primeros 128 bytes del archivo
bufin.Read(bytes, 0,128);
Console.WriteLine("Allocated bytes: " + Encoding.ASCII.GetString(bytes));
}
public static void LeerArchivoTxt()
{
string fileName =@"C:\Users\j.cruz\Archivo.xml";
FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read);
StreamReader reader = new StreamReader(stream);while (reader.Peek() > -1) Console.WriteLine(reader.ReadLine());
reader.Close();
}
public static void EscribirArchivoTxt()
{
string fileName= @"C:\Users\j.cruz\Archivo.xml";
FileStream stream = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.Write);
StreamWriter writer = new StreamWriter(stream);...
Regístrate para leer el documento completo.