如何使用FTP检查目录是否存在? [英] how to check directory exists or not using FTP?

查看:610
本文介绍了如何使用FTP检查目录是否存在?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

帮我使用FTP检查目录

Help me to check the directory using FTP

using BytesRoad.Net.Ftp;

FtpClient ftpClient = new FtpClient();
// use passive mode
ftpClient.PassiveMode = true;

int timeout = 0;
// connect to the specified FTP server
ftpClient.Connect(timeout,"URL ", 11 );
ftpClient.Login(timeout,USERNAME,PASSWORD);

rootDirectory = ftpClient.GetWorkingDirectory(timeout);
target = rootDirectory + "/testfolder " ;



我需要检查"target(testfolder)"是否存在
保存测试文档文件之前.
没有像directoryexists这样的扩展名.



I need to check the "target(testfolder)" is exists or not
before saving the test document file.
There is no extensions like directoryexists.

string file_to_save = target + "/test.doc";
// synchronously upload the file
ftpClient.PutFile(0, file_to_save , @"C:\test.doc" );
ftpClient.Disconnect(timeout);



谢谢
SwaxRak



Thanks
SwaxRak

推荐答案

如果标准System.Net.FtpWebRequest可以完美地完成工作,为什么还要使用第三方BytesRoad?
如果仍要使用BytesRoad,请询问该库的作者.

我建议您使用标准的System.Net,它是……很好,标准,有据可查,经过测试,可以完美地完成工作.在此处查看您的问题(非常简单)的可能答案之一:
http://stackoverflow.com/questions/2769137/c- how-to-check-if-an-ftp-directory是否存在 [
Why would you use third-party BytesRoad if standard System.Net.FtpWebRequest would do the job perfectly?

If you still want to use BytesRoad, ask the author(s) of this library.

I recommend you use standard System.Net which is… well, standard, well documented, tested and perfectly do the job. See one of the possible answers to your (very simple) Question here:
http://stackoverflow.com/questions/2769137/c-how-to-check-if-an-ftp-directory-exists[^].

—SA


这篇关于如何使用FTP检查目录是否存在?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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