
04/03/2013, 13:10
|
| | Fecha de Ingreso: febrero-2012
Mensajes: 15
Antigüedad: 13 años Puntos: 1 | |
Comparar texto de un Archivo.txt con textbox Hola, tengo un codigo, lo que hace es que al poner un codigo se Valida el programa y funciona completamente via Archivo de TxT.
Lo que quiero hacer es tener un archivo txt con codigos ej:
Xjk-lpi
q12-123
sad-21k
Y Que el programa cuando se ejecute le pida un codigo y que lo escrito en el textbox se compare con ese archivo con codigos.
Si 1 codigo es correcto, que escriba el codigo en otro archivo.txt y lo guarde.
Mi codigo actual es este:
Lo que hace es que cada vez que se ejecute escriba un numero. 1 o 2 o 3.
Cuando llegue a 3 escribe FIN y esto hace que se necesite un codigo para hacerlo funcionar, entonces cuando llegue este momento, quiero hacer que descargue el txt, lo lea y compare.
Código:
If EsAdministrador() = False Then
MsgBox("Abrir como administrador")
End
Else
If Not File.Exists("C:\License.txt") Then
File.Create("C:\License.txt")
Pausa(5)
Using sw As StreamWriter = New StreamWriter("C:\License.txt")
sw.Write("1")
sw.Close()
End Using
Pausa(3)
Else
File.Copy("C:\License.txt", "C:\Templicense.txt")
Dim fileReader As System.IO.StreamReader
fileReader = My.Computer.FileSystem.OpenTextFileReader("C:\Templicense.txt")
Dim stringReader As String
While (fileReader.EndOfStream = False)
stringReader = fileReader.ReadLine()
If stringReader = "1" Then
Using sw As StreamWriter = New StreamWriter("C:\License.txt")
sw.Write("2")
sw.Close()
End Using
Tengo este codigo para descargar el archivo.txt y leerlo pero no lee linea por linea, o no se hacerlo funcionar :( necesito ayuda :)
Como hacer que este codigo lea linea por linea hasta el final y si no encuentra el texto igual que salga error, si encuentra en alguna linea un texto igual, que salga correcto.
Ejemplo textbox.text = "Hola a todos"
Archivo.txt =
Nada
hola
loco
fail
Hola a todos
Que compruebe, si encuentra igualdad, siga, sino, error.
Código:
Dim Estadoprg As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create("https://dl.dropbox.com/s/i7zqatn9kmp57mx/Estado.txt?dl=1")
Dim estadoread As System.Net.HttpWebResponse = Estadoprg.GetResponse()
Dim srestado As System.IO.StreamReader = New System.IO.StreamReader(estadoread.GetResponseStream())
Dim estadoprograma As String = srestado.ReadToEnd()
If estadoprograma = "On" Then
Else
MsgBox(estadoprograma, MsgBoxStyle.Information)
End
End If
Catch
MsgBox("Error de Conexion", MsgBoxStyle.Critical)
End
End Try
Por favor unas ayuditas.
Gracias! Saludos |