OK Tak men jeg får vildt mange fejle alle dem her
Error 1 Name 'WebRequest' is not declared. C:\Documents and Settings\All Users\Dokumenter\Visual Studio 2005\Projects\en test\en test\Form1.vb 8 51 en test
Error 2 Type 'FtpWebRequest' is not defined. C:\Documents and Settings\All Users\Dokumenter\Visual Studio 2005\Projects\en test\en test\Form1.vb 8 78 en test
Error 3 Name 'WebRequestMethods' is not declared. C:\Documents and Settings\All Users\Dokumenter\Visual Studio 2005\Projects\en test\en test\Form1.vb 9 22 en test
Error 3 Name 'WebRequestMethods' is not declared. C:\Documents and Settings\All Users\Dokumenter\Visual Studio 2005\Projects\en test\en test\Form1.vb 9 22 en test
Error 4 Type 'Stream' is not defined. C:\Documents and Settings\All Users\Dokumenter\Visual Studio 2005\Projects\en test\en test\Form1.vb 12 26 en test
Error 5 Type 'FtpWebResponse' is not defined. C:\Documents and Settings\All Users\Dokumenter\Visual Studio 2005\Projects\en test\en test\Form1.vb 35 72 en test
Error 6 Declaration expected. C:\Documents and Settings\All Users\Dokumenter\Visual Studio 2005\Projects\en test\en test\Form1.vb 38 1 en test
Error 7 Declaration expected. C:\Documents and Settings\All Users\Dokumenter\Visual Studio 2005\Projects\en test\en test\Form1.vb 40 13 en test
Error 7 Declaration expected. C:\Documents and Settings\All Users\Dokumenter\Visual Studio 2005\Projects\en test\en test\Form1.vb 40 13 en test
Error 9 'End Sub' must be preceded by a matching 'Sub'. C:\Documents and Settings\All Users\Dokumenter\Visual Studio 2005\Projects\en test\en test\Form1.vb 42 5 en test
Og kode ser sådan ud her nu har laver ´lidt om på den før
fik jeg mange fler fejl:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
End Sub
Public Shared Sub Upload(ByVal localfile As String, ByVal ftpurl As String, ByVal bin As Boolean)
Dim req As Net.FtpWebRequest = DirectCast(WebRequest.Create(ftpurl), FtpWebRequest)
req.Method = WebRequestMethods.Ftp.UploadFile
req.UseBinary = bin
If bin Then
Dim instm As Stream = New FileStream(localfile, FileMode.Open, FileAccess.Read)
Dim outstm As IO.Stream = req.GetRequestStream()
Dim b As Byte() = New Byte(10000) {}
Dim n As Integer
n = instm.Read(b, 0, b.Length)
While n > 0
outstm.Write(b, 0, n)
n = instm.Read(b, 0, b.Length)
End While
instm.Close()
outstm.Close()
Else
Dim sr As IO.StreamReader = New IO.StreamReader(localfile)
Dim sw As IO.StreamWriter = New IO.StreamWriter(req.GetRequestStream())
Dim line As String
line = sr.ReadLine()
While line IsNot Nothing
sw.WriteLine(line)
line = sr.ReadLine()
End While
sr.Close()
sw.Close()
End If
Dim resp As FtpWebResponse = DirectCast(req.GetResponse(), FtpWebResponse)
End Sub
eksempler på kald:
Upload("C:\X.java", "
ftp://anonymous:xxxxxx@arnepc3/X.java", False)
Upload("C:\X.class", "
ftp://anonymous:xxxxxx@arnepc3/X.class", True)
End Sub
End Class