ciao!
avrei la necessità di caricare dei files su ftp da pagina asp.net webform.
sto provando così, ma mi da sempre errore perchè non trova il file scelto dall'utente:
questo l'errore:codice:Private Sub upFile(sender As Object, e As EventArgs) Handles UploadButton.Click Try Dim hfc As HttpFileCollection = Request.Files For i As Integer = 0 To hfc.Count - 1 Dim hpf As HttpPostedFile = hfc(i) If hpf.ContentLength > 0 Then Dim ftpRequest As FtpWebRequest = DirectCast(WebRequest.Create(New Uri("ftp://........./TEST_UPLOAD/" & Path.GetFileName(hpf.FileName))), FtpWebRequest) ftpRequest.Method = WebRequestMethods.Ftp.UploadFile ftpRequest.Credentials = New NetworkCredential("***", "***") ftpRequest.UseBinary = True ftpRequest.UsePassive = True Dim buffer As Byte() = Nothing 'Load the file Using stream As FileStream = File.OpenRead(Path.GetFullPath(hpf.FileName)) buffer = New Byte(CInt(stream.Length - 1)) {} stream.Read(buffer, 0, buffer.Length) End Using 'Upload file Using reqStream As Stream = ftpRequest.GetRequestStream() reqStream.Write(buffer, 0, buffer.Length) End Using End If Next Catch ex As Exception Diagnostics.Debug.WriteLine(ex.Message) End Try End Sub
ovviamente il file è preso dal controllo specifico:codice:Il file 'C:\Program Files (x86)\IIS Express\Apple stitched.jpg' non è stato trovato.
qualche dritta al riguardo??codice:<asp:FileUpload ID="FileUploadControl" runat="server" AllowMultiple="true" /> <asp:Button runat="server" ID="UploadButton" Text="Upload" />

Rispondi quotando
