Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
C# / VB.NET - problema downlaod da ftp aiuto
Forum - C# / VB.NET - problema downlaod da ftp aiuto - Pagina 2

Pagine: [ 1 2 3 4 5 ] Precedente | Prossimo
Avatar
riseofapocalypse (Ex-Member)
Pro


Messaggi: 150
Iscritto: 08/07/2009

Segnala al moderatore
Postato alle 12:56
Venerdì, 17/07/2009
Posta il codice, non posso aiutarti così :k:

PM Quote
Avatar
Master_VB (Normal User)
Pro


Messaggi: 148
Iscritto: 26/06/2009

Segnala al moderatore
Postato alle 13:05
Venerdì, 17/07/2009
Codice sorgente - presumibilmente VB.NET

  1. Download.Credentials = New NetworkCredential(My.Settings.username_ftp, My.Settings.password_ftp)
  2.         Try
  3.             Dim newFileData() As Byte = Download.DownloadData(URL)
  4.             Dim fileString As String = System.Text.Encoding.UTF8.GetString(newFileData)
  5.             Console.WriteLine(fileString)
  6.             IO.File.WriteAllBytes(filedir, newFileData)
  7.         Catch ex As WebException
  8.             Console.WriteLine(ex.Message)
  9.         End Try



poi nell'evento progresschanged ho messo questo:

Codice sorgente - presumibilmente C# / VB.NET

  1. ProgressBar1.Value = e.ProgressPercentage
  2.         NessunDownloadInCorsoToolStripMenuItem.Text = "Download in corso..." & e.ProgressPercentage & "%"
  3.         ToolStripStatusLabel1.Text = "Download in corso..." & e.ProgressPercentage & "%"
  4.         TextBox3.Text = e.BytesReceived()
  5.         TextBox5.Text = e.TotalBytesToReceive()


ma da http funziona invece da ftp non aumenta niente non funziona...:(

PM Quote
Avatar
riseofapocalypse (Ex-Member)
Pro


Messaggi: 150
Iscritto: 08/07/2009

Segnala al moderatore
Postato alle 13:12
Venerdì, 17/07/2009
Allora! Prima di tutto queste due righe puoi toglierle:
Codice sorgente - presumibilmente C# / VB.NET

  1. Dim fileString As String = System.Text.Encoding.UTF8.GetString(newFileData)
  2. Console.WriteLine(fileString)


Erano solo un esempio :) poi...prova a mettere Application.DoEvents nell'evento ProgressChanged :k:

PM Quote
Avatar
Master_VB (Normal User)
Pro


Messaggi: 148
Iscritto: 26/06/2009

Segnala al moderatore
Postato alle 17:58
Venerdì, 17/07/2009
allora ho scaricato un file html...anche con application.doevents() non mi danno segni di vita gli avanzamenti e in più ho provato a scaricare un mp3 e in http funziona a meraviglia mentre in ftp si blocca con questo errore:

Eccezione first-chance di tipo 'System.Net.WebException' in System.dll

e addirittura a volte non trova il file! come mi veniva prima...boh! non si capisce più niente!:(

Ultima modifica effettuata da Master_VB il 17/07/2009 alle 18:01
PM Quote
Avatar
riseofapocalypse (Ex-Member)
Pro


Messaggi: 150
Iscritto: 08/07/2009

Segnala al moderatore
Postato alle 21:11
Venerdì, 17/07/2009
Hai provato a portare il codice da sincrono ad asincrono?

PM Quote
Avatar
Master_VB (Normal User)
Pro


Messaggi: 148
Iscritto: 26/06/2009

Segnala al moderatore
Postato alle 21:21
Venerdì, 17/07/2009
cioè come devo fare?

PM Quote
Avatar
riseofapocalypse (Ex-Member)
Pro


Messaggi: 150
Iscritto: 08/07/2009

Segnala al moderatore
Postato alle 21:35
Venerdì, 17/07/2009
Prova così:
Codice sorgente - presumibilmente VB.NET

  1. Download.Credentials = New NetworkCredential(username, password)
  2.         Try
  3.             Download.DownloadDataAsync(New Uri(url))
  4.         Catch ex As WebException
  5.             MsgBox(ex.Message)
  6.         End Try


E poi:
Codice sorgente - presumibilmente VB.NET

  1. Private Sub Download_DownloadDataCompleted(ByVal sender As Object, ByVal e As System.Net.DownloadDataCompletedEventArgs) Handles Download.DownloadDataCompleted
  2.         IO.File.WriteAllBytes(filename, e.Result)
  3.     End Sub
  4.     Private Sub Download_DownloadProgressChanged(ByVal sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs) Handles Download.DownloadProgressChanged
  5.         ProgressBar1.Value = e.ProgressPercentage
  6.         NessunDownloadInCorsoToolStripMenuItem.Text = "Download in corso... " & e.ProgressPercentage & "%"
  7.         ToolStripStatusLabel1.Text = "Download in corso... " & e.ProgressPercentage & "%"
  8.         TextBox3.Text = e.BytesReceived
  9.         TextBox5.Text = e.TotalBytesToReceive
  10.     End Sub


Dovrebbe funzionare! :k:

PM Quote
Avatar
Master_VB (Normal User)
Pro


Messaggi: 148
Iscritto: 26/06/2009

Segnala al moderatore
Postato alle 21:45
Venerdì, 17/07/2009
funziona...cioè il file lo scarica ma con i progressi ancora niente non vanno avanti!:(

PM Quote
Pagine: [ 1 2 3 4 5 ] Precedente | Prossimo