Ver Mensaje Individual
  #1  
Antiguo 01-09-2015
deliriun deliriun is offline
Miembro
 
Registrado: ago 2014
Posts: 51
Reputación: 10
deliriun Va por buen camino
Question Mostrar un Texto alojado en DropBox

Hola qué tal?

Estoy ingresando al mundo de la programación en Delphi con el IDE de Lazarus y necesito un poco de ayuda por no decir mucha para traducir un código....

Anteriormente programaba en visual basic.net en el cual empleaba un código del usuario de youtube: vbtutorialesabc , excelente por cierto...
El código tenía la función de leer un archivo de texto almacenado en DropBox, una vez hecho eso el contenido era dividido por lineas y en cada linea habían campos... Algo así

DELIRIUN|ABANTO|skillteam2001@gmail.com

Divididos por una barra cada campo representaba un Nombre,Clave,e - mail ...etc
Técnicamente lo mismo que hace una base de datos, sin embargo yo utilizaba DropBox porque me parecía mucho más sencillo que una base de datos común...

Una vez que ya se leía el archivo de Texto, el programa te pedía ingresar en un TextBox (Edit) el primer campo... En este caso DELIRIUN y con ese primer campo ya se hacía la búsqueda y te presentaba los demás campos asignados con ese nombre de usuario...

Espero me haya dejado explicar... el código en vb.net es el siguiente:::


Código:
Imports System.Net
Imports System.IO

Public Class Form1
    'CARGA LA RUTA A LA INFORMACION EN DROPBOX
    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Try
            TextBoxURL.Text = My.Computer.FileSystem.ReadAllText(Application.StartupPath & "\URL.txt")
        Catch ex As Exception
        End Try
    End Sub

    Private Sub ButtonBUSCAR_Click(sender As System.Object, e As System.EventArgs) Handles ButtonBUSCAR.Click
        'BUSCA LOS DATOS EN EL ARCHIVO DROPBOX CORRESPONDIENTE 
        Dim URL As String = Nothing
        Dim MISTREAM As Stream = Nothing
        Try
            URL = TextBoxURL.Text
            URL = URL.Replace("dl=0", "raw=1")
            Dim CLIENTE As New WebClient
            MISTREAM = CLIENTE.OpenRead(URL)
        Catch ex As Exception
            MsgBox(ex.Message)
            Me.Close()
        End Try
        ' SI ENCUENTRA LA COINCIDENCIA PRESENTA LOS RESULTADOS
        Dim LECTOR As New StreamReader(MISTREAM)
        Dim ENCONTRADO As Boolean = False
        While LECTOR.Peek >= 0
            Dim LINEA As String = LECTOR.ReadLine().Replace("{}", "")
            Dim DATOS As String() = LINEA.Split("|")
            If DATOS(0) = TextBoxNOMBRE.Text.ToUpper Then
                TextBoxAPELLIDO.Text = DATOS(1)
                TextBoxMAIL.Text = DATOS(2)
                TextBoxTELEFONO.Text = DATOS(3)
                ENCONTRADO = True
                Exit While
            End If
        End While
        ' AVISO SI NO ENCUENTRA LOS DATOS 
        If ENCONTRADO = False Then
            MsgBox("NO EXISTE NINGUN REGISTRO PARA  " & TextBoxNOMBRE.Text)
        End If
        MISTREAM.Close()
    End Sub

    Private Sub Form1_FormClosed(sender As Object, e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
        'GUARDA LA ULTIMA URL UTILIZADA
        Try
            My.Computer.FileSystem.WriteAllText(Application.StartupPath & "\URL.txt", TextBoxURL.Text, False)
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub
End Class

Por cierto el programa necesita la URL del archivo alojado en DropBox...

Muchas Gracias de antemano
Responder Con Cita