当前位置:首页 » 文件传输 » 文件名获取ftp文件
扩展阅读
webinf下怎么引入js 2023-08-31 21:54:13
堡垒机怎么打开web 2023-08-31 21:54:11

文件名获取ftp文件

发布时间: 2023-01-12 23:16:27

A. FTP获取文件名以及文件路径

既然是服务器,而且是linux 你用一个tomcat 当做服务器,可以配置一下tomcat,就可以直接ftp 模式访问文件夹了。

B. 用bat批处理命令获取ftp服务器目录下的文件名及子目录下的文件名...各位大神帮帮忙

@echooff
seth=192.168.1.100
setu=ftpuser
setp=12345678
echoopen%h%>ftp.txt
echo%u%>>ftp.txt
echo%p%>>ftp.txt
echodir>>ftp.txt
echobye>>ftp.txt
ftp-s:ftp.txt>ftpdir.txt
echoopen%h%>ftp.txt
echo%u%>>ftp.txt
echo%p%>>ftp.txt
for/f"tokens=4"%%iin('findstr"<DIR>"ftpdir.txt')do(
echocd%%~i>>ftp.txt
echodir>>ftp.txt
echocd..>>ftp.txt)
echobye>>ftp.txt
ftp-s:ftp.txt>ftpfile.txt
notepadftpfile.txt

C. 如何进行FTP文件的搜索

FTP文件服务器由一些组织结构为内部方柏霓而搭建的,如医院,学校、政府等,相当于集团的云端一样,实时的进行数据共享,发图片文件服务器会消耗很大的宽带资源,占用较大的网速,而且不盈利,在非公益组织的ftp是不允许他人登陆的,所以一般市面上并不常见。

通过远程连接ftp即可连接登陆,然后就能够下载所需文件了,但是要知道局域网的ip,登陆可能还需要账号及密码,使用服务器管理工具即可登陆连接,既方便,又快捷。

D. windowsftp如何获取文件夹下所有的文件

可以通过命令窗口来打开所有的文件。具体步骤如下:
点击win+R后输入cmd打开dos命令窗口。
打开需获取文件名的位置。
获取名称,命令格式:dir/b文件目标盘符文件夹位置(可省略)目标名称.目标后缀。
获取文件大小及文件名、修改时间(文件大小需处理)。
Microsoft Surface是一个由微软所开发的第一款平面电脑,结合硬件与软件的新技术,用家可以直接用手或声音对屏幕作出指令,触摸和其他外在物理物来和电脑进行交互,毋须再依赖会令手部劳损的鼠标与键盘。

E. 怎么用ftp 取文件 命令

熟悉并灵应用FTP内部命令便使用者并收事半功倍效
FTP命令行格式:ftp -v -d -i -n -g [主机名]其
-v显示远程服务器所响应信息;
-n限制ftp自登录即使用;
.n etrc文件;
-d使用调试式;
-g取消全局文件名
ftp使用内部命令(括号表示选项):
1.![cmd[args]]:本机执行交互shellexitftp环境:!ls*.zip.
2.$ macro-ame[args]:执行宏定义macro-name.
3.account[password]:提供登录远程系统功访问系统资源所需补充口令
4.append local-file[remote-file]:本文件追加远程系统主机若未指定远程系统文件名则使用本文件名
5.ascii:使用ascii类型传输式
6.bell:每命令执行完毕计算机响铃
7.bin:使用二进制文件传输式
8.bye:退ftp程
9.case:使用mget远程主机文件名写转写字母
10.cd remote-dir:进入远程主机目录
11.cp:进入远程主机目录父目录
12.chmod mode file-name:远程主机文件file-name存取式设置mode:chmod 777 a.out
13.close:断与远程服务器ftp(与open应)
14.cr:使用asscii式传输文件车换行转换行

F. 如何 用Java 实现 获取FTP服务器上的所有文件名,已知FTP的密码,用户名!远程获取!

public void ftpJdomFile(String dir) throws FileNotFoundException, IOException{
//创立根节点
// 下面这个方法是列出指定目录下的所有文件和文件夹
List dirslist=Arrays.asList(new File(dir).listFiles());
for (Iterator i = dirslist.iterator(); i.hasNext();) {
// System.out.println(i.next()); // line 1
String s=i.next().toString();
if (new File(s).isFile()) {
System.out.println(s+"-文件");
}
if (new File(s).isDirectory()) {
System.out.println(s+"++++++++文件夹");
ftpJdomFile(s);
}

}

}

G. Linux下如何获取FTP文件名和大小

path='' #这里的$1,换成你需要的路径名,或者你不换,通过shell的参数传入
for dirlist in $(find ${path} -name *.xml)
do
echo ${dirlist}
查找,删除,比较都在这做
done

H. C# 获取Ftp某个目录下的所有文件(不要文件夹)

我在之前做过一个FTP的客户端工具。
drw 文件夹
-rw 文件(有扩展名或无扩展名)
我是根据服务端返回的报文进行分析获取的列表。
给你一些代码片段:
/// <summary>
/// 获取指定目录下的文件和文件夹。
/// </summary>
/// <param name="path">要获取的目录</param>
/// <param name="WRMethods">要发送到FTP服务器的密令。</param>
/// <returns></returns>
public string[] GetFileList(string path, string WRMethods)//从ftp服务器上获得文件列表
{
WebResponse response;
string[] downloadFiles;
int conut = 4;
StringBuilder result = new StringBuilder();
Connect(path);
if (FTPVariable.IsUseProxy_ftp)
{
reqFTP.Proxy = FtpProxy.GetFtpSelectProxy(FTPVariable.FtpCommand_transferProxyName);
}
reqFTP.ReadWriteTimeout = 12000;
//如果不应销毁到服务器的连接,则为 true;否则为 false。默认值为 true。
//
reqFTP.Method = WRMethods;
try
{
response = (FtpWebResponse)reqFTP.GetResponse();
goto Ftp_lbl_03;
}
catch (WebException webex)
{
GetReply(webex.Message);
if (ReplyCode == 530)// 未登录。
{
goto Ftp_lbl_04;
}
else if (ReplyCode == 550)
{
goto Ftp_lbl_04;
}
else
{
FtpManage.SetLog("获取列表超时,等候1秒后重试!");
goto Ftp_lbl_01;
}
}
Ftp_lbl_01:
try
{
FtpManage.SetLog("正在连接服务器 " + FtpRemoteHost);
response = GetRequest(path, WRMethods);
}
catch (WebException)
{
FtpManage.SetLog("获取列表超时,等候1秒后重试!");
downloadFiles = null;
System.Threading.Thread.Sleep(1000);
if (conut == 0)
{
goto Ftp_lbl_02;
}
conut--;
goto Ftp_lbl_01;
}
catch (Exception ex)
{
MSG.Show(ex.Message, Global.GetRS["msgTilteError"], MessageBoxButton.OK, MsgIco.Error);
FtpManage.SetLog("命令执行失败,原因:" + ex.Message);
downloadFiles = null;
return downloadFiles;
}
Ftp_lbl_03:
StreamReader reader = new StreamReader(response.GetResponseStream(), System.Text.Encoding.Default);//中文文件名
string line = reader.ReadLine();
while (line != null)
{
result.Append(line);
result.Append("\n");
line = reader.ReadLine();
}
if (result.Length == 0)
{
return null;
}
// to remove the trailing '\n'
result.Remove(result.ToString().LastIndexOf('\n'), 1);
reader.Close();
response.Close();
FtpManage.SetLog("命令已成功执行");
return result.ToString().Split('\n');
Ftp_lbl_04:
FtpManage.SetLog(ReplyInfo);
return null;
Ftp_lbl_02:
FtpManage.SetLog("550 获取列表失败,无法连接远程服务器!");
FtpManage.ftpmanage.IsRefurbish = true;
return null;
}
/// <summary>
/// 获取指定目录下的文件和文件夹。
/// </summary>
/// <param name="path">要获取的目录</param>
/// <returns></returns>
public string[] GetFileList(string path)//从ftp服务器上获得文件列表
{
return GetFileList(FTPVariable.FtpURLhead + FtpRemoteHost + "/" + path, WebRequestMethods.Ftp.ListDirectory);
}

/// <summary>
/// 获取指定目录下的文件和文件夹。
/// </summary>
/// <returns></returns>
public string[] GetFileList()//从ftp服务器上获得文件列表
{
return GetFileList(FTPVariable.FtpURLhead + FtpRemoteHost + "/", WebRequestMethods.Ftp.ListDirectory);
}

/// <summary>
/// 获取目录和文件名,返回目录表。
/// </summary>
/// <param name="path">要获取的目录</param>
/// <returns></returns>
public string[] GetCatalog_FileList(string path)
{
string[] fountainhead = GetFileList(FTPVariable.FtpURLhead + FtpRemoteHost + "/" + path, WebRequestMethods.Ftp.ListDirectoryDetails);
string[] Catalog = null;
if (fountainhead == null)
{
return null;
}
Catalog = new string[fountainhead.Length];
for (int i = 3; i < fountainhead.Length; i++)
{
Catalog[i - 3] += fountainhead[i].Substring(55, fountainhead[i].Length - 55) + "&";//FileName
Catalog[i - 3] += fountainhead[i].Substring(30, 12) + "&";//FileSize
Catalog[i - 3] += fountainhead[i].Substring(42, 13) + "&";//AmendDate
Catalog[i - 3] += fountainhead[i].Substring(0, 3) + "&";
}
return Catalog;
}

I. C#如何取得ftp上面的所有文件夹里面的所有文件名,求源码。。。。

连接方法:
string ftpServerIP = "";

string ftpUserID = "";

string ftpPassword = "";

string TempPath = Path.GetTempPath();

FtpWebRequest reqFTP;
DataTable dt;
private void Connect(String path)//连接ftp
{

try
{
reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(path));
reqFTP.UseBinary = true;
reqFTP.Credentials = new NetworkCredential(ftpUserID, ftpPassword);
}
catch (Exception){
Response.Write("<srcipt>alert('连接失败!')</script>");
}
获取方法:
private string[] GetFileList(string path, string WRMethods)
{
string[] downloadFiles;
StringBuilder result = new StringBuilder();
try
{
Connect(path);
reqFTP.Method = WRMethods;
WebResponse response = reqFTP.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream(), System.Text.Encoding.Default);
string line = reader.ReadLine();

while (line != null)
{
result.Append(line);
result.Append("\n");
line = reader.ReadLine();

}
result.Remove(result.ToString().LastIndexOf('\n'), 1);
reader.Close();
response.Close();
return result.ToString().Split('\n');

}

catch (Exception)
{

downloadFiles = null;

return downloadFiles;
}
}
调用:
string[] str = GetFileList("ftp://" + ftpServerIP + "/" + path, WebRequestMethods.Ftp.ListDirectoryDetails);

数组就是ftp文件夹下的所有文件名,如果要判断ftp根下面的是文件还是文件夹。需要解字符串才行!