VB .NET Check FTP account if already exist

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



VB .NET Check FTP account if already exist



I try to create an application for Windows OS for can sync files from computer with a FTP account.



I need a function in Visual Basic for check if FTP account exist.



For example:


Public Function CheckAccountFTP(ByVal host As String, ByVal user As String, ByVal pass As String) As Boolean
'' Function Content ...
... Try/Catch with what ...
End Function



What I can use for this?





.NET Framework doesn't have a specific function for checking FTP account existence; otherwise the framework will be bloated with CheckRdpAccount, CheckSshAccount, CheckTelnetAccount, CheckSmptAccount, so on and so forth. Do you have idea how FTP makes connections? If you can guide me, I can figure out the code.
– Gqqnbig
Aug 10 at 0:23





All you can do is try to connect and catch the exception if it fails. You almost certainly won't be able to distinguish between an invalid user name and a valid user name with an invalid password though. Most systems aren't going to tell someone who is trying to hack into the system that they are halfway there.
– jmcilhinney
Aug 10 at 1:10




1 Answer
1



I think I can use this function:


Public Function CheckAccountFTP(ByVal sHost As String, ByVal sUser As String, ByVal sPassword As String) As Boolean
Dim bStatus As Boolean
Dim request = DirectCast(WebRequest.Create(sHost), FtpWebRequest)
request.Method = WebRequestMethods.Ftp.ListDirectory
request.Credentials = New NetworkCredential(sUser, sPassword)
Try
Using request.GetResponse()
bStatus = True
End Using
Catch
bStatus = False
End Try
Return bStatus
End Function



And then it will be used:


If CheckAccountFTP("ftp://localhost", "aninu", "123123123") = True Then
'' OK ...
Else
'' Not OK ...
End If





What's the point of such a function? Why don't you directly do your operation (sync files)?
– Martin Prikryl
Aug 10 at 18:55






In my application, I check if FTP account exist and then start to sync all files. This app, check file by file if exist on FTP account and if not exist or exist but is not last version of file, sync this (here I can add size limitation or a limitation for file extension and another things).
– Aninu Alin
Aug 10 at 20:10






Your didn't answer my question. You have only repeated, what we already know from your question.
– Martin Prikryl
Aug 19 at 6:28






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard