当前位置:首页 » 文件管理 » 设置ftp客户端下载文件的路径

设置ftp客户端下载文件的路径

发布时间: 2022-08-10 10:04:09

ftp文件下载到指定文件夹

ftp的命令行里有lcd 命令,就是切换本地目录。你试下。

例如:
c:\>ftp
open 192.168.1.5
user test test
cd data //切换FTP服务上的目录
lcd c:\data\201004 //切换本地目录
get xxxx.dat
by

//随手写的例子,未经实际测试。

Ⅱ 用FTP下载如何下载到指定的文件夹啊

我记得在linux下是默认下载到你当前目录下,如果你想下载到指定的目录下,先进到这个目录,然后再ftp

Ⅲ 怎么改FTP下载的路径

下次下载时,你先仔细地把出现的对话框读一遍,机器会默认你现有的下载软件,你看看是什么,
至于下载的东西,对话框中会有下载路径告诉你,
你把下载对话框中的东西都抄下来。
打开:我的电脑-C盘-
顺着下载路径就会找到你要看的东西,
有时下载 ,会让你自己选择下载地点。
不会很难,问问周围的人,自己找些基础的电脑书看一下,慢慢就会好,

Ⅳ ftp下载的文件在哪里

一般是在
c:\documents
and
settings\administrator\my
documents
你也可以
用ftp的命令
dir
列出目录
然后
对该文件目录
进行分析
找出
ftp
b1.gd.cn
user:
password:
get
test.rar
c:\
bye
这样
就可以把
下载的文件到
c盘了。

Ⅳ ftp的路径怎么设置

问一下,你是想做ftp上传下载么?

首先你需要安装一个ftp服务端程序,启动起来,然后下载一个ftp客户端程序,测试能不能连接,首先这一块儿需要测试通过。
代码ftp上传下载
2.1 上传代码:
import java.io.File;
import java.io.FileInputStream;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPReply;

public class test {

private FTPClient ftp;
/**
*
* @param path 上传到ftp服务器哪个路径下
* @param addr 地址
* @param port 端口号
* @param username 用户名
* @param password 密码
* @return
* @throws Exception
*/
private boolean connect(String path,String addr,int port,String username,String password) throws Exception {
boolean result = false;
ftp = new FTPClient();
int reply;
ftp.connect(addr,port);
ftp.login(username,password);
ftp.setFileType(FTPClient.BINARY_FILE_TYPE);
reply = ftp.getReplyCode();
if (!FTPReply.isPositiveCompletion(reply)) {
ftp.disconnect();
return result;
}
ftp.changeWorkingDirectory(path);
result = true;
return result;
}
/**
*
* @param file 上传的文件或文件夹
* @throws Exception
*/
private void upload(File file) throws Exception{
if(file.isDirectory()){
ftp.makeDirectory(file.getName());
ftp.changeWorkingDirectory(file.getName());
String[] files = file.list();
for (int i = 0; i < files.length; i++) {
File file1 = new File(file.getPath()+"\\"+files[i] );
if(file1.isDirectory()){
upload(file1);
ftp.changeToParentDirectory();
}else{
File file2 = new File(file.getPath()+"\\"+files[i]);
FileInputStream input = new FileInputStream(file2);
ftp.storeFile(file2.getName(), input);
input.close();
}
}
}else{
File file2 = new File(file.getPath());
FileInputStream input = new FileInputStream(file2);
ftp.storeFile(file2.getName(), input);
input.close();
}
}
public static void main(String[] args) throws Exception{
test t = new test();
t.connect("", "localhost", 21, "yhh", "yhhazr");
File file = new File("e:\\uploadify");
t.upload(file);
}
}
2.2 下载代码
这里没有用到filter,如果用filter就可以过滤想要的文件。

public class Ftp {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Ftp ftp = new Ftp();
String hostname = "www.strawberry.com";
Integer port = 21;
String username = "username";
String password = "password";
String remote = "/c.txt";
String local = "/home/tin/LeonChen/FTP/";
try {
ftp.connect(hostname, port, username, password);
System.out.println("接收状态:"+ftp.download(remote, local));
ftp.disconnect();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

private FTPClient ftpClient = new FTPClient();

/*
* * 连接到FTP服务器
* * @param hostname 主机名
* * @param port 端口
* * @param username 用户名
* * @param password 密码
* * @return 是否连接成功
* * @throws IOException
*/
private boolean connect(String hostname, int port, String username,
String password) throws IOException {
ftpClient.connect(hostname, port);
ftpClient.setControlEncoding("UTF-8");
if (FTPReply.isPositiveCompletion(ftpClient.getReplyCode())) {
if (ftpClient.login(username, password)) {
return true;
}
}
disconnect();
return false;
}

/*
* 从FTP服务器上下载文件,支持断点续传,上传百分比汇报
*
* @param remote 远程文件路径
*
* @param local 本地文件路径
*
* @return 上传的状态
*
* @throws IOException
*/
public DownloadStatus download(String remote, String local)
throws IOException {
// 设置被动模式
ftpClient.enterLocalPassiveMode();
// 设置以二进制方式传输
ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
DownloadStatus result;
// 检查远程文件是否存在
FTPFile[] files = ftpClient.listFiles(new String(remote
.getBytes("UTF-8"), "iso-8859-1"));
if (files.length != 1) {
System.out.println("远程文件不存在");
return DownloadStatus.Remote_File_Noexist;
}
long lRemoteSize = files[0].getSize();
String fildName = files[0].getName();
// 本地存在文件,进行断点下载
File f = new File(local+fildName);
if (f.exists()) {
long localSize = f.length();
if (localSize >= lRemoteSize) {
System.out.println("本地文件大于远程文件,下载中止");
return DownloadStatus.Local_Bigger_Remote;
}

// 进行断点续传,并记录状态
FileOutputStream out = new FileOutputStream(f, true);
ftpClient.setRestartOffset(localSize);
InputStream in = ftpClient.retrieveFileStream(new String(remote.getBytes("UTF-8"), "iso-8859-1"));
byte[] bytes = new byte[1024];
long step = lRemoteSize / 100;
long process = localSize / step;
int c;
while ((c = in.read(bytes)) != -1) {
out.write(bytes, 0, c);
localSize += c;
long nowProcess = localSize / step;
if (nowProcess > process) {
process = nowProcess;
if (process % 10 == 0)
System.out.println("下载进度:" + process);
// TODO 更新文件下载进度,值存放在process变量中
}
}
in.close();
out.close();
boolean isDo = ftpClient.completePendingCommand();
if (isDo) {
result = DownloadStatus.Download_From_Break_Success;
} else {
result = DownloadStatus.Download_From_Break_Failed;
}
} else {
OutputStream out = new FileOutputStream(f);
InputStream in = ftpClient.retrieveFileStream(new String(remote.getBytes("UTF-8"), "iso-8859-1"));
byte[] bytes = new byte[1024];
long step = lRemoteSize / 100;
long process = 0;
long localSize = 0L;
int c;
while ((c = in.read(bytes)) != -1) {
out.write(bytes, 0, c);
localSize += c;
long nowProcess = localSize / step;
if (nowProcess > process) {
process = nowProcess;
if (process % 10 == 0)
System.out.println("下载进度:" + process);
// TODO 更新文件下载进度,值存放在process变量中
}
}
in.close();
out.close();
boolean upNewStatus = ftpClient.completePendingCommand();
if (upNewStatus) {
result = DownloadStatus.Download_New_Success;
} else {
result = DownloadStatus.Download_New_Failed;
}
}
return result;
}

private void disconnect() throws IOException {
if (ftpClient.isConnected()) {
ftpClient.disconnect();
}
}

}

Ⅵ linux中,如何将ftp中的文件下载到指定位置

在指定的目录下登录FTP,然后get 文件就行了。下载下来的文件就在当前目录,也就是你指定的目录。

Ⅶ 用ftp命令下载的文件默认放在哪

楼主您好,ftp下载的文件默认的路径是您用ftp用户登录之后所在的目录,您可以在用ftp连接上服务器之后,使用pwd查看路径。

Ⅷ linux 通过FTP下载文件存放位置在哪

通过终端使用ftp命令下载文件的话,没指定保存的路径的话,在哪个路径执行的ftp命令下载的东西就保存在那个位置。用其他ftp客户端的话,通常默认下载地址是在你的用户的家目录下。

Ⅸ 电脑上说的FTP地址指的是什么怎么设置自己的FTP呢

FTP(File Transfer Protocal),是用于Internet上的控制文件的双向传输的协议。同时,它也是一个应用程序。

设置ftp服务器的方法:

工具/原料

IIS .net framework 电脑

方法/步骤

1、打开【控制面板】->【程序和功能】->【启用或关闭 windows 功能】,窗口中,勾选【Internet Information Services】下面的【FTP服务器】三个选项,点击【确定】。

Ⅹ 怎样更改FTP下载文件存放位置

如果你用的是迅雷的话 你点击下载的时候会有一个对话框 提示你存放路径 那个时候你就可以选择你想存放的位置 了 如果你没有用软件的话 同上 方法一样

热点内容
app什么情况下找不到服务器 发布:2025-05-12 15:46:25 浏览:713
php跳过if 发布:2025-05-12 15:34:29 浏览:466
不定时算法 发布:2025-05-12 15:30:16 浏览:130
c语言延时1ms程序 发布:2025-05-12 15:01:30 浏览:164
动物园灵长类动物配置什么植物 发布:2025-05-12 14:49:59 浏览:732
wifi密码设置什么好 发布:2025-05-12 14:49:17 浏览:147
三位数乘两位数速算法 发布:2025-05-12 13:05:48 浏览:396
暴风影音缓存在哪里 发布:2025-05-12 12:42:03 浏览:539
access数据库exe 发布:2025-05-12 12:39:04 浏览:627
五开的配置是什么 发布:2025-05-12 12:36:37 浏览:363