Jump to content
Windows Dragon

Upload não funciona

Recommended Posts

Windows Dragon

Boas pessoal... quero fazer upload para o meu ftp server mas nao estou a conseguir.... Quer dizer... ele acaba de fazer o upload quando eu vou a fazer o download já pelo file zila diz que o ficheiro nao é reconhecido... este é o codigo

Private Sub bw_DoWork(ByVal sender As Object, ByVal e As DoWorkEventArgs)
        Dim worker As BackgroundWorker = CType(sender, BackgroundWorker)

        For i = 1 To 10
            If bw.CancellationPending = True Then
                e.Cancel = True
                Exit For
                ' Perform a time consuming operation and report progress.

                My.Computer.Network.UploadFile(Application.StartupPath & "\Data\playerdb.mdb", "ftp://ftp.xtreemhost.com/htdocs/BlackTomatoData/playerdb.mdb", "svusername", "********")
                bw.ReportProgress(i * 10)
            End If
    End Sub

Como repararam o codigo é a parte de um background worker... mas relacionado com o upload nao tenho mais nenhum codigo

Share this post

Link to post
Share on other sites
        Dim ftpRequest As System.Net.FtpWebRequest = _
        DirectCast(System.Net.WebRequest.Create("ftp://ftp.URLXPTO.net/public_html/Teste.txt"), System.Net.FtpWebRequest)
        ftpRequest.Credentials = New System.Net.NetworkCredential("username", "password")
        ftpRequest.Method = System.Net.WebRequestMethods.Ftp.UploadFile

        Dim fileUp() As Byte = System.IO.File.ReadAllBytes("C:\Teste.txt")
        Dim ftpStream As System.IO.Stream = ftpRequest.GetRequestStream()

        ftpStream.Write(fileUp, 0, fileUp.Length)

Share this post

Link to post
Share on other sites
Windows Dragon

O codigo está a funcionar... mas acho que o problema é no background worker parece-me que está a fazer várias vezes upload...

Share this post

Link to post
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.