如何访问ftp文件并显示该文件夹中的文件目录

njhyh 2006-01-12 10:40:49
如何访问ftp文件并显示该文件夹中的文件目录,帮帮忙,很急!
...全文
725 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
njhyh 2006-01-25
  • 打赏
  • 举报
回复
谢谢
!!
caoqinghua 2006-01-25
  • 打赏
  • 举报
回复
FTP Client library in C#
Author: Jaimon Mathew

This is the C# version of an FTP client library which is originally written in Java. The library will be compiled to a DLL file. A test program is also included to show the usage of this library. You will get more details about FTP from its rfc. Most of the commands are supported here. File upload & download methods are capable enough of doing resuming also.

The given test program is a console based application. I抦 inviting somebody on the net to develop a front end application with this library.

/*
FTPFactory.cs
Better view with tab space=4

Written by Jaimon Mathew (jaimonmathew@rediffmail.com)
Rolander,Dan (Dan.Rolander@marriott.com) has modified the
download
method to cope with file name with path information. He also
provided
the XML comments so that the library provides Intellisense
descriptions.

use the following line to compile
csc /target:library /out:FTPLib.dll /r:System.DLL FTPFactory.cs
*/

using System;
using System.Net;
using System.IO;
using System.Text;
using System.Net.Sockets;

namespace FtpLib
{

public class FTPFactory
{

private string
remoteHost,remotePath,remoteUser,remotePass,mes;
private int remotePort,bytes;
private Socket clientSocket;

private int retValue;
private Boolean debug;
private Boolean logined;
private string reply;

private static int BLOCK_SIZE = 512;

Byte[] buffer = new Byte[BLOCK_SIZE];
Encoding ASCII = Encoding.ASCII;

public FTPFactory()
{

remoteHost = "localhost";
remotePath = ".";
remoteUser = "anonymous";
remotePass = "jaimon@school2000.co.uk";
remotePort = 21;
debug = false;
logined = false;

}

///
/// Set the name of the FTP server to connect to.
///
/// Server name
public void setRemoteHost(string remoteHost)
{
this.remoteHost = remoteHost;
}

///
/// Return the name of the current FTP server.
///
/// Server name
public string getRemoteHost()
{
return remoteHost;
}

///
/// Set the port number to use for FTP.
///
/// Port number
public void setRemotePort(int remotePort)
{
this.remotePort = remotePort;
}

///
/// Return the current port number.
///
/// Current port number
public int getRemotePort()
{
return remotePort;
}

///
/// Set the remote directory path.
///
/// The remote directory path
public void setRemotePath(string remotePath)
{
this.remotePath = remotePath;
}

///
/// Return the current remote directory path.
///
/// The current remote directory path.
public string getRemotePath()
{
return remotePath;
}

///
/// Set the user name to use for logging into the remote
server.
///
/// Username
public void setRemoteUser(string remoteUser)
{
this.remoteUser = remoteUser;
}

///
/// Set the password to user for logging into the remote
server.
///
/// Password
public void setRemotePass(string remotePass)
{
this.remotePass = remotePass;
}

///
/// Return a string array containing the remote directory's
file list.
///
///
///
public string[] getFileList(string mask)
{

if(!logined)
{
login();
}

tteagle 2006-01-20
  • 打赏
  • 举报
回复
去找一个叫FtpFactory的类,很简单,我刚刚用过,挺好用,显示目录用该类中的GetFileList方法就可以了,如果真找不到,我可以贴上来
njhyh 2006-01-12
  • 打赏
  • 举报
回复
在线等
njhyh 2006-01-12
  • 打赏
  • 举报
回复
希望有源代码

16,721

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧