I have a problem that is turning my head upside down! I am building a connection DLL with FTP server but soon I face the following problem:
I need to declare the class in a form to open the connection to the FTP Server, but in this class declaration the variable must contain the FTPServ , User and Password . But there's the problem. I can not create string for a class, I have programming time but in javascript for games!
Example:
Imports Servidor.FTP
Dim FTPServ As New FTP("Servidor", "Usuário" , "Senha")
But Visual Studio speaks the following
Too many arguments to "Public Sub New"
I declare the Hostname, User and Password Property and I used the Sub New but nothing is right.
DLL Home Code
Imports System.IO
Imports System.Net
Imports System.Net.NetworkCredential
Public Class FTPServ
Dim URIFTP As String = ""
Dim SWServidor As WebRequest = FtpWebRequest.Create(URIFTP)
Public _Host As String
Public _Password As String
Public _User As String
Public Property HostnameP As String
Get
Return _Host
End Get
Set(ByVal V As String)
End Set
End Property
Public Property UsuárioP As String
Get
Return _Host
End Get
Set(ByVal V As String)
End Set
End Property
Public Property SenhaP As String
Get
Return _Password
End Get
Set(ByVal V As String)
End Set
End Property
Public Sub New(ByVal usuário As String, ByVal Senha As String, ByVal Domain As String)
Me._Host = Domain
Me._Password = Senha
Me._User = usuário
End Sub
Public Function UploadFile(ByVal URLArquivo As String, Destino As String)
' SWServidor.Credentials = New NetworkCredential(Hostname, Usuário, Senha)
SWServidor.Method = WebRequestMethods.Ftp.UploadFile
Try
Dim ByteFile() As Byte = System.IO.File.ReadAllBytes(Destino)
Dim MyStream As System.IO.Stream = SWServidor.GetRequestStream()
MyStream.Write(ByteFile, 0, ByteFile.Length)
MyStream.Close()
MyStream.Dispose()
Catch ex As Exception
MsgBox("Erro")
End Try
End Function
End Class