Upload fil ftp
Const localFile As String = "C:\xxx\xxx\xxx\xxxxxxxxx.xxx"Const remoteFile As String = "xxxxxxxx.xxx"
Const host As String = "ftp://xxxxxx.xx/xxxx/"
Const username As String = "xxxxxx.xxx"
Const password As String = "xxxxxxxxxxxxx"
Dim URI As String = host & remoteFile
Dim ftp As System.Net.FtpWebRequest = CType(System.Net.FtpWebRequest.Create(URI), System.Net.FtpWebRequest)
ftp.Credentials = New System.Net.NetworkCredential(username, password)
ftp.KeepAlive = False
ftp.UseBinary = True
ftp.Method = System.Net.WebRequestMethods.Ftp.DownloadFile
Using response As System.Net.FtpWebResponse = CType(ftp.GetResponse, System.Net.FtpWebResponse)
Using responseStream As IO.Stream = response.GetResponseStream
Using fs As New IO.FileStream(localFile, IO.FileMode.Create)
Dim buffer(2047) As Byte
Dim read As Integer = 0
Do
ProgressBar1.PerformStep()
read = responseStream.Read(buffer, 0, buffer.Length)
fs.Write(buffer, 0, read)
Loop Until read = 0 'see Note(1)
CheckBox1.Checked = False
ProgressBar1.Value = 0
responseStream.Close()
fs.Flush()
fs.Close()
End Using
responseStream.Close()
End Using
response.Close()
End Using
Dette stykke kode har jeg fra the code pproject. Der stod jeg ved hjælp af ftp.GetRequestStream men jeg kan ikke overskue hvordan det skal sættes ind.. håber nogen kan hjælpe...