Comprimir y Extraer archivos






Esta clase representa el formato de datos gzip, que utiliza un algoritmo estándar del sector para archivos sin pérdidas de compresión y descompresión.El formato incluye un valor de comprobación de la prueba cíclica de redundancia para detectar daños en los datos. El formato de datos gzip utiliza el mismo algoritmo que la DeflateStream clase, pero se puede extender para utilizar otros formatos de compresión.



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO.Compression;
using System.IO;


namespace GZipStream_I
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)//Comprimir
{
OpenFileDialog ofd = new OpenFileDialog();
if (ofd.ShowDialog() == DialogResult.OK)
{
Compresion(ofd.FileName);
}
}

private void button2_Click(object sender, EventArgs e)//Descomprimir
{
OpenFileDialog ofd = new OpenFileDialog();
if (ofd.ShowDialog() == DialogResult.OK)
{
Descompresion(ofd.FileName);
}

}

public static void Compresion(string NombreArchivo)
{
FileStream Archivo;
try
{
// Leemos el archivo a comprimir
Archivo = new FileStream(NombreArchivo, FileMode.Open, FileAccess.Read,                                     FileShare.Read);

//Definimos el buffer con el tamaño del archivo
byte[] btBuffer = new byte[Archivo.Length];

//Almacenamos los bytes del archivo en el buffer
int intCount = Archivo.Read(btBuffer, 0, btBuffer.Length);
Archivo.Close();

//Definimos el nuevo stream que nos va a permitir grabar el zip
FileStream Salida = new FileStream(NombreArchivo + ".zip", FileMode.Create,                                   FileAccess.Write);

//Rutina de compresion usando GZipStream
GZipStream gzsArchivo = new GZipStream(Salida,                                                                                 CompressionMode.Compress, true);

//Escribimos el resultado
gzsArchivo.Write(btBuffer, 0, btBuffer.Length);
gzsArchivo.Close();

//Cerramos el archivo
Salida.Flush();
Salida.Close();

MessageBox.Show("Compresion realizada correctamente al archivo: " +                                               NombreArchivo + ".zip");
}
catch (Exception ex)
{
MessageBox.Show("Ocurrió un error al comprimir: " + ex.Message);

}
}


Código de Barras




using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Codigo_de_Barras_I
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button2_Click(object sender, EventArgs e)
{
Application.Exit();
}

private void button1_Click(object sender, EventArgs e)
{
Zen.Barcode.Code128BarcodeDraw codigobarras=Zen.Barcode.BarcodeDrawFactory.Code128WithChecksum;
pictureBox1.Image = codigobarras.Draw(textBox1.Text, 100);
}
}
}


Código QR - Quick Response






Un código QR (del inglés Quick Response code, "código de respuesta rápida") es un módulo para almacenar información en una matriz de puntos o en un código de barras bidimensional. Fue creado en 1994 por la compañía japonesa Denso Wave, subsidiaria de Toyota. Presenta tres cuadrados en las esquinas que permiten detectar la posición del código al lector. El objetivo de los creadores (un equipo de dos personas en Denso Wave, dirigido por Masahiro Hara) fue que el código permitiera que su contenido se leyera a alta velocidad.


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace QRCode_I
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
Zen.Barcode.CodeQrBarcodeDraw codigoqr = Zen.Barcode.BarcodeDrawFactory.CodeQr;
pictureBox1.Image = codigoqr.Draw(textBox1.Text, 50);
}

private void button2_Click(object sender, EventArgs e)
{
Application.Exit();
}
}
}




Radio Online




using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Radio_Internet
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
Application.Exit();
}

private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
axWindowsMediaPlayer1.URL = @"http://radio.skypherence.com:8000/radiomozart";
}

private void radioButton2_CheckedChanged(object sender, EventArgs e)
{
axWindowsMediaPlayer1.URL = @"http://streaming202.radionomy.com:80/ABC-Classic";
}
}
}



Reproductor con Windows Media Player





using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Reproductor_WMP
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog abrir = new OpenFileDialog();
abrir.Filter = "Todos los archivos|*.*";
if (abrir.ShowDialog() == DialogResult.OK)
{
axWindowsMediaPlayer1.URL = abrir.FileName;
}
}

private void button2_Click(object sender, EventArgs e)
{
Application.Exit();
}
}
}