Comandos:
Mayuscula +F10
diskpart
list disk
select disk 0 (el caso del disco )
clean
Este blog es para aportar el conocimiento en diferentes áreas de los sistemas computacionales y de la vida
GridView gdv = (GridView)e.Row.Cells[2].FindControl(“gdvProductos”);Hay que considerar que el evento RowDataBoundse ejecuta segun la cantidad de registros que se muestran en el GirdView es decir, si tu GridView tiene 10 filas, este evento se ejecutará 10 veces.
using System;
using System.IO;
using System.Collections;
StreamReader objReader = new StreamReader("c:\\test.txt");string sLine="";
ArrayList arrText = new ArrayList();
while (sLine != null)
{
sLine = objReader.ReadLine();
if (sLine != null)
arrText.Add(sLine);
}
objReader.Close();foreach (string sOutput in arrText)
Console.WriteLine(sOutput);
Console.ReadLine();
using System;
using System.IO;
using System.Collections;
namespace TextFileReader_csharp
{
/// <summary>
/// Descripción de resumen para Class1.
/// </summary>
class Class1
{
static void Main(string[] args)
{
StreamReader objReader = new StreamReader("c:\\test.txt");
string sLine="";
ArrayList arrText = new ArrayList();
while (sLine != null)
{
sLine = objReader.ReadLine();
if (sLine != null)
arrText.Add(sLine);
}
objReader.Close();
foreach (string sOutput in arrText)
Console.WriteLine(sOutput);
Console.ReadLine();
}
}
}HourFromNow = Datetime() + 3600
WeekAgo = Datetime() - (7*24*3600)
// Método para procesar un fichero public void procesarFichero() { // Definimos un StreamReader StreamReader lector; string linea = ""; try{ lector = File.OpenText(fichero); // Lee linea a linea while ( (linea = lector.ReadLine()) != null){ //hacemos lo que queramos } // Cerramos la conexion lector.Close(); } catch (Exception e){ System.Console.WriteLine("Problemas al cargar el fichero.{0}", e); } }
Este código nos muestra como validar el TextBox1 para que acepte solo letras y como validar el TextBox2 para que acepte solo números.
En Visual Studio .NET abra un nuevo proyecto de VisualBasic .NET
Seleccionando la plantilla de Aplicación para Windows
En el Form1 que se crea automáticamente agregue dos TextBox
No les cambie el nombre Deben de quedar como TextBox1 y TextBox2
Luego valla al código del Form1 y agregue las siguientes líneas:
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As _ System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If e.KeyChar.IsLetter(e.KeyChar) Then
e.Handled = False
ElseIf e.KeyChar.IsControl(e.KeyChar) Then
e.Handled = False
ElseIf e.KeyChar.IsSeparator(e.KeyChar) Then
e.Handled = False
Else
e.Handled = True
End If
End Sub
Private Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As _ System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress
If e.KeyChar.IsDigit(e.KeyChar) Then
e.Handled = False
ElseIf e.KeyChar.IsControl(e.KeyChar) Then
e.Handled = False
Else
e.Handled = True
End If
End Sub
Listo ahora puede ejecutar su proyecto con F5 y probar la aplicación.
NOTA:
Si desea que en el TextBox1 aparezcan las letras solo en MAYUSCULAS o minúsculas solo
tiene que cambiar la propiedad CharacterCasing del TextBox1
Me.TextBox1.CharacterCasing = CharacterCasing.Upper 'para MAYUSCULASMe.TextBox1.CharacterCasing = CharacterCasing.Lower 'para minúsculas
o
Me.TextBox1.CharacterCasing = CharacterCasing.Normal


<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
Ingrese nombre de usuario:<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="TextBox1" ErrorMessage="RequiredFieldValidator">Debe ingresar el
nombre de usuario.</asp:RequiredFieldValidator>
<br />
<asp:Button ID="Button1" runat="server" Text="Confirmar" />
</div>
</form>
</body>
</html>
Como sabemos este código HTML se genera en forma automática cuando creamos cada control y configuramos sus propiedades.Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Button1.Click
If Me.IsValid Then
Me.Response.Redirect("Default2.aspx")
End If
End Sub
End Class
La propiedad IsValid del WebForm almacena true si todos los controles de validación dispuestos en el formulario se validan correctamente. Es decir en este problemas si se ingresa algún caracter en el control TextBox luego se puede pasar a la página “Default2.aspx”.

Partial Class Default2
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Button1.Click
If Me.IsValid Then
Me.Response.Redirect("Default3.aspx")
End If
End Sub
End Class
Es decir redireccionamos a la próxima página en caso que todos los controles de validación del formulario se verifiquen correctos (en este problema solo tenemos un control de tipo RangeValidator, pero en muchos casos veremos que en un formulario puede haber más de un control de validación)If Me.RangeValidator1.IsValid Then
Me.Response.Redirect("Default3.aspx")
End If
Es decir verificamos la propiedad IsValid del control RangeValidator (si tenemos un solo control en el formulario preguntar por la propiedad IsValid del webform o del RangeValidator el resultado será idéntico)

Partial Class Default3
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Button1.Click
If Me.IsValid Then
Me.Response.Redirect("Default4.aspx")
End If
End Sub
End Class


Protected Sub CustomValidator1_ServerValidate(ByVal source As Object, ByVal args As _
System.Web.UI.WebControls.ServerValidateEventArgs) Handles CustomValidator1.ServerValidate
Dim valor As Integer = args.Value
If valor Mod 5 = 0 Then
args.IsValid = True
Else
args.IsValid = False
End If
End Sub
El parámetro args tiene dos propiedades fundamentales, una almacena el valor del control que estamos validando y otra llamada IsValid que debemos asignarle el resultado de nuestra validación.Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
If Me.IsValid Then
Me.Response.Redirect("Default5.aspx")
End If
End Sub


Partial Class Default5
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
If Me.IsValid Then
Me.Response.Redirect("Default6.aspx")
End If
End Sub
End Class

Data Source = ServidorSQL; Initial Catalog = BaseDatos; Integrated Security = Truedata source = ServidorSQL; initial catalog = BaseDatos; user id = Usuario; password = Contraseñadata source = ServidorSQL; initial catalog = BaseDatos; user id = Usuario; password = ContraseñaImports System.DataImports System.Data.SqlClientDim sCnn As StringsCnn = "data source = ServidorSQL; initial catalog = BaseDatos; user id = Usuario; password = Contraseña"Dim sSel As String = "SELECT * FROM NombreTabla"Dim da As SqlDataAdapterDim dt As New DataTableTry da = New SqlDataAdapter(sSel, sCnn) da.Fill(dt) Me.GridView1.DataSource = dt Me.GridView1.DataBind() LabelInfo.Text = String.Format("Total datos en la tabla: {0}", dt.Rows.Count) Catch ex As Exception LabelInfo.Text = "Error: " & ex.Message End Tryusing System.Data;using System.Data.SqlClient;string sCnn; sCnn = "data source = ServidorSQL; initial catalog = BaseDatos; user id = Usuario; password = Contraseña";string sSel = "SELECT * FROM NombreTabla";SqlDataAdapter da;DataTable dt = new DataTable();try{ da = new SqlDataAdapter(sSel, sCnn); da.Fill(dt); this.GridView1.DataSource = dt; this.GridView1.DataBind(); LabelInfo.Text = String.Format("Total datos en la tabla: {0}", dt.Rows.Count);}catch(Exception ex){ LabelInfo.Text = "Error: " + ex.Message;}
Producto,Cantidad,Precio
Sierra eléctrica,1,250
Máscara de hockey,1,15.50
Machete,5,2.70
Detergente para ropa (con quita-manchas),1,10
Delantal,2,7.25
Afilador,3,5
// asumiendo que tenemos// using System.Data.OleDb;// using System.Data;// en este connection string:// HDR=Yes : indica que el primer registro contiene los encabezados // (nombres) de las columnas, no datos.// FMT=Delimited : indica que el los campos están delimitados por un caracter// (coma por default).string connectionString =@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\DirectorioDeArchivosCSV;" +"Extended Properties='text;HDR=Yes;FMT=Delimited'";DataTable dt = new DataTable("miTabla");
using (OleDbConnection conn = new OleDbConnection(connectionString))
using (OleDbDataAdapter da = new OleDbDataAdapter("SELECT * FROM jason.csv", conn))
{da.Fill(dt);
}
// hacer algo con los datos en el DataTable// asumiendo que tenemos// using System.Data.OleDb;// using System.Data;// en este connection string:// HDR=Yes : indica que el primer registro contiene los encabezados // (nombres) de las columnas, no datos.// FMT=Fixed : indica que el los campos están en posiciones fijas y el tamaño// de cada campo se especifican con un archivo SCHEMA.INI// en el mismo directorio donde está el archivo a leer.string connectionString =@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\DirectorioDeArchivosTXT;" +"Extended Properties='text;HDR=Yes;FMT=Fixed'";DataTable dt = new DataTable("miTabla");
using (OleDbConnection conn = new OleDbConnection(connectionString))
using (OleDbDataAdapter da = new OleDbDataAdapter("SELECT * FROM jason.txt", conn))
{da.Fill(dt);
}
// hacer algo con los datos en el DataTable[jason.txt]
Format=FixedLength
Col1=Producto Char Width 40
Col2=Cantidad Long Width 10
Col3=Precio Double Width 10
// asumiendo que tenemos // using System.Data.OleDb;// using System.Data;// using System.IO;public enum TipoDeArchivoPlano { Delimited, Fixed }
public static DataTable LeerArchivoPlano(
FileInfo archivo, bool tieneEncabezado, TipoDeArchivoPlano tipoDeArchivo )
{if (!archivo.Exists)throw new FileNotFoundException(
"No se encontró el archivo especificado");string conEncabezado = tieneEncabezado ? "YES" : "NO";
string connectionString = String.Format(
@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};" +"Extended Properties='text;HDR={1};FMT={2}'",archivo.DirectoryName, conEncabezado, tipoDeArchivo.ToString());
DataTable dt = new DataTable("miTabla");
using (OleDbConnection conn = new OleDbConnection(connectionString))
using (OleDbDataAdapter da =
new OleDbDataAdapter("SELECT * FROM " + archivo.Name, conn))
{da.Fill(dt);
}
return dt;}
DataTable dt = LeerArchivoPlano(new FileInfo(@"C:\DirectorioDeArchivosCSV\jason.csv"),
true, TipoDeArchivoPlano.Delimited);