2

我想将 FileZilla 与我用 C# 编写的应用程序集成。请有人给我看示例代码或显示示例代码的网站。

虽然我在网上找到了一篇文章,那篇文章说“应用程序与 FileZilla 集成太慢了”。但我不知道我能不能忍受那么晚。所以我想挑战。

4

4 回答 4

3

To support FTP/SFTP or any other protocol in C# you can do it in 3 ways:

1. NEW APP PROCESS - Start an app that does the FTP communication in separate process, and be able to control what file to download, where to save it and to tell the app to terminate when download is finished. This way, you can use FileZilla only if it lets you pass certain parameters in command line, like the URI of the resource you want to transfer through FTP/SFTP, and the path where the file should be saved to. And as I can see HERE this could work.

To start the process and pass it command line arguments in C# you would do something like this:

static void StartNewProcess(string app, string args)
{
    ProcessStartInfo startInfo = new ProcessStartInfo();
    startInfo.FileName = app;   //full app path
    startInfo.Arguments = args; //command line arguments
    startInfo.CreateNoWindow = true; //dont create app window
    startInfo.WindowStyle = ProcessWindowStyle.Hidden; //hide app from taskbar
    Process.Start(startInfo);
}

Now you can execute FileZila app, pass it args containing file URL and let it do its job... But you cant know how long will it take to download the file, when the download is ended, do you need to log in to get it...

2. EXISTING CLASS LIBRARY - Include a Class Library that is written by someone else, that does the job. This way you are in TOTAL control of the process. And as many other suggested, this would be a perfect way for you. Many answers here contain good class libraries that you can use and be happy with the results.

3. HOME-MADE CLASS LIBRARY - Open RFC 959, read it all and write your code... (Now 2. sounds better, doesn't it? :D)

于 2011-03-02T11:07:28.717 回答
2

Filezilla 是一个 GUI FTP 客户端,您不能用它来“编写”SFTP 操作(它只接受一组非常有限的命令行参数)

您必须寻找第三方 C# 组件或自己编写一个(不推荐)来完成这项工作。

于 2011-03-02T10:44:31.480 回答
0

如果您需要在应用程序中通过 SSH/SFTP 发送文件,我推荐使用SharpSSH 。

于 2011-03-02T11:02:17.263 回答
0

要从 C# 应用程序支持 FTP 或 SFTP,您可以使用外部库,例如 Chilkat http://www.chilkatsoft.com/ftp-2-dotnet.asp中的库。我用它,效果很好!

理论上,您也可以自己使用套接字连接来实现 FTP 协议,但您应该省去这个麻烦 -> 不要重新发明轮子......

于 2011-03-02T10:42:41.340 回答