列出VB.NET中ftp的所有文件 [英] List all the files from ftp in VB.NET

查看:88
本文介绍了列出VB.NET中ftp的所有文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将在列表框中显示我在ftp服务器中的所有文件,以便用户可以选择文件并下载。我在文本框中键入我的ftp服务器IP地址ftp://192.168.10.1/然后单击按钮显示ftp中列出的所有文件。它显示消息无效url:主机名无法解析。但是,我可以通过键入正确的ftp地址查看Web浏览器中的所有文件。顺便说一句,我使用ftpclient.dll作为参考来自https://www.codeproject.com/Articles/11991/An-FTP-client- library-for-NET。请帮我解决问题或找出其他方法。感谢您的帮助。



我尝试过的:



I going to do the list box to show all my files in the ftp server so that the user can select the files and download it. After i typed my ftp server ip address "ftp://192.168.10.1/ in the textbox then clicked the button for display all files listed in the ftp. It shows the messages invalid url : the hostname cannot be parsed. But, I can view all my files in the web browser by typing the correct ftp address. By the way, I am using the ftpclient.dll for the references from https://www.codeproject.com/Articles/11991/An-FTP-client-library-for-NET. Please help me to solve the problems or figure out other ways to doing it. Thanks for your helps.

What I have tried:

Public Class FileSharingForm
Private FTPDownloader As New Utilities.FTP.FTPclient

Private Sub FileSharingForm_Load(sender As Object, e As EventArgs) Handles     MyBase.Load
btnChangeDirectory.Enabled = False
FTPDownloader.Hostname = txtServer.Text.Trim
FTPDownloader.Username = txtUsername.Text
FTPDownloader.Password = txtPassword.Text

End Sub

Private Sub btnHomeDirectory_Click(sender As Object, e As EventArgs) Handles      btnHomeDirectory.Click
FTPDownloader.CurrentDirectory = /;
RefreshList()
End Sub

Private Sub RefreshList()
ListFTPFiles.Items.Clear()
Try
For Each file In FTPDownloader.ListDirectoryDetail()
    ListFTPFiles.Items.Add(file.Filename)
Next
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub

End Class

推荐答案

你应该把你的问题发布到文章末尾的论坛,以便代码的作者看到它。
You should post your question in the forum at the end of the article so the author of the code sees it.


这篇关于列出VB.NET中ftp的所有文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆