當前位置:首頁 » 文件管理 » 設置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 瀏覽:711
php跳過if 發布:2025-05-12 15:34:29 瀏覽:465
不定時演算法 發布:2025-05-12 15:30:16 瀏覽:129
c語言延時1ms程序 發布:2025-05-12 15:01:30 瀏覽:163
動物園靈長類動物配置什麼植物 發布:2025-05-12 14:49:59 瀏覽:732
wifi密碼設置什麼好 發布:2025-05-12 14:49:17 瀏覽:146
三位數乘兩位數速演算法 發布:2025-05-12 13:05:48 瀏覽:395
暴風影音緩存在哪裡 發布:2025-05-12 12:42:03 瀏覽:539
access資料庫exe 發布:2025-05-12 12:39:04 瀏覽:627
五開的配置是什麼 發布:2025-05-12 12:36:37 瀏覽:363