Jump to content

Formato URI


Ivo Pereira

Recommended Posts

  • Replies 40
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Eu tenho um ficheiro de controlo de actualizações num server..e basicamente o que eu faço é:

dim i as integer
Dim Contents As String = MyWebClient.DownloadString('path_http")
Dim Variaveis() As String = Split(Contents, Chr(Keys.LineFeed)) ' Aqui estou a usar um ficheiro em que cada linha corresponde a um valor distinto - vou desdobrar a variável content pela variaveiss()

'Depois..por exemplo

for i = 0 to variaveis.lenght-1
msgbox variaveis(i)
next

'Este ciclo vai dar-te uma msgbox de cada um dos diferentes valores assumidos pela variavel

Não sei se ficou mais claro agora....

Claro que depende dos dados que tens no txt no server... e como eles estão arrumados (em linhas, separados por ";" ou por ",", ...)

Quando te pedirem peixe.... ensina-os a Pescar!!Hum..lálálálá!!

Link to comment
Share on other sites

Ora bem, de volta a casa, e aqui está o código:

    Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
        Dim networkCredentials As New Net.NetworkCredential()
        With networkCredentials
            .UserName = "b31_1980023"
            .Password = "xxxxxxxxxx"
        End With
        MyWebClient.Credentials = networkCredentials
        txtInfo = MyWebClient.DownloadString(SessionAccess.ToString)
        txtInfoArray = txtInfo.Split(vbNewLine)
        If txtInfoArray.Contains(txtID.Text And txtPassword.Text) Then
            MsgBox("Login correct!", MsgBoxStyle.Information)
        Else
            MsgBox("Login incorrect!", MsgBoxStyle.Critical)
        End If
    End Sub

Dá o erro:

A conversão da cadeia "UnVqLxLy" para o tipo 'Long' não é válida.

PS: O código UnVqLxLy é um código gerado aleatoriamente por uma função que tenho.

O erro dá na parte:

        If txtInfoArray.Contains(txtID.Text And txtPassword.Text) Then

O que está mal aqui?

Cumps 😞

Link to comment
Share on other sites

o problema entao esta a ser na ligação ao web server.

poque é que estas a usar as credential's... isto aqui e suposto funcionar por download directo via http... as credentials usam-se para ftp por exemplo... é suposto existir algum tipo de autenticação?

Quando te pedirem peixe.... ensina-os a Pescar!!Hum..lálálálá!!

Link to comment
Share on other sites

o problema entao esta a ser na ligação ao web server.

poque é que estas a usar as credential's... isto aqui e suposto funcionar por download directo via http... as credentials usam-se para ftp por exemplo... é suposto existir algum tipo de autenticação?

No webserver? Mas eu tenho previamente uma ligação com o webserver de upload que funciona bem...

Link to comment
Share on other sites

ok...

Recapitulando.. esta variável txtInfoArray deveria ser do tipo txtInfoArray(), porque provavelmente quando fazes:

txtInfo = MyWebClient.DownloadString(SessionAccess.ToString)
        txtInfoArray = txtInfo.Split(vbNewLine)

ele vai criar um array a partir do split do txtinfo.

quando te referires doravante ao  txtInfoArray deverias utiliza-lo em conjunto com o índice..por exemplo 

If txtInfoArray(0).Contains(txtID.Text And txtPassword.Text) Then
            MsgBox("Login correct!", MsgBoxStyle.Information)

Não sei se fui mais claro agora... mas ainda nao percebi bem o que retorna o teu

txtInfo = MyWebClient.DownloadString(SessionAccess.ToString)

Quando te pedirem peixe.... ensina-os a Pescar!!Hum..lálálálá!!

Link to comment
Share on other sites

o que devolve a leitura desse ficheiro... ou por ontro lado... qual é a string devolvida?

Acho que isto te explica tudo 😞 :

   Private Sub main_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Focus()
        txtNewID.Text = RandomNumber(1000000, 10000)
        txtNewPassword.Text = RandomPassword(8)
        swriter.WriteLine("===================================================")
        swriter.WriteLine("             X-Trade under Copyrights              ")
        swriter.WriteLine("===================================================")
        swriter.WriteLine("ID: " & txtNewID.Text)
        swriter.WriteLine("Password: " & txtNewPassword.Text)
        swriter.WriteLine("Date: " & Today.Date.ToLongDateString)
        swriter.WriteLine("Time: " & TimeOfDay.ToLongTimeString())
        swriter.WriteLine("===================================================")
        swriter.Close()
        My.Computer.Network.UploadFile(My.Computer.FileSystem.SpecialDirectories.Temp & "/access.tmp", "ftp://ftp.byethost31.com/xtrade.isgreat.org/htdocs/xtrade/access.tmp", "b31_1980023", "xxxxxxxxxx")

    End Sub
Link to comment
Share on other sites

se fosse eu... na criação do ficheiro de controlo punha um ";" no final de cada linha

Depois no Download e verificação fazia o seguinte

Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
        Dim networkCredentials As New Net.NetworkCredential()
        With networkCredentials
            .UserName = "b31_1980023"
            .Password = "xxxxxxxxxx"
        End With
        MyWebClient.Credentials = networkCredentials
        txtInfo = MyWebClient.DownloadString(SessionAccess.ToString)
        txtInfoArray = txtInfo.Split(";")
        If txtInfoArray(3).Contains(txtID.Text) And txtInfoArray(4).Contains(txtPassword.Text) Then
            MsgBox("Login correct!", MsgBoxStyle.Information)
        Else
            MsgBox("Login incorrect!", MsgBoxStyle.Critical)
        End If
    End Sub

Só deve ser preciso verificar se o indice do da variavel txtInfoArray é mesmo aquele

Quando te pedirem peixe.... ensina-os a Pescar!!Hum..lálálálá!!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.