當前位置:首頁 » 文件管理 » ftp互相轉移

ftp互相轉移

發布時間: 2022-09-23 12:13:51

A. 如何把一個ftp里的資料轉移到另一個空間商提供的FTP

真的只能先用本地電腦中轉,但是空間商一般都可以先打包壓縮再傳到另一個FTP里去再解壓這樣就沒有那麼麻煩了

B. FTP伺服器文件遷移的問題

存儲還是用linux吧,windows沒有linux靈活,為了以後好遷移,還是改成linux的好。

C. 請教:FTP伺服器轉移

您在伺服器中安裝一下FTP服務端軟體。
在本地電腦上安裝一下FTP客戶端,客戶端通過服務端的IP、FTP用戶名、密碼就可以轉移數據了。
海騰數據張毅龍為您回答,希望可以幫到您。

D. 如何從一個ftp的文件轉移到另一個ftp

只能重新上傳了。你是想遷移ftp伺服器嗎?用愛米雲共享網盤的,遷移伺服器非常方便,功能完全可以代替ftp,比ftp還好用

E. java如何實現將FTP文件轉移到另一個FTP伺服器上

你有FTPClient就比較好辦,假如你的兩台FTP伺服器分別為fs1和fs2

在本地開發代碼思路如下:

  1. 通過FTPClient連接上fs1,然後下載(可以循環批量下載)到本地伺服器,保存到一個臨時目錄。

  2. 下載完成後,FTPClient斷開與fs1的連接,記得必須logout。

  3. 本地伺服器通過FileInputStream將剛下載到臨時目錄的文件讀進來,得到一個List<File>集合。

  4. 通過FTPClient連接上fs2,循環List<File>集合,將文件上傳至fs2的特定目錄,然後清空臨時目錄,上傳完畢後,斷開fs2的連接,同樣必須logout。

F. C# 將FTP文件轉移到另一個FTP伺服器上如何實現

C# ftp上傳ftp
/// <summary>
/// 上傳文件
/// </summary> /
// <param name="fileinfo">需要上傳的文件</param>
/// <param name="targetDir">目標路徑</param>
/// <param name="hostname">ftp地址</param> /
// <param name="username">ftp用戶名</param> /
// <param name="password">ftp密碼</param>
public static void UploadFile(FileInfo fileinfo, string targetDir, string hostname, string username, string password)
{ //1. check target
string target;
if (targetDir.Trim() == "")
{ return; }
target = Guid.NewGuid().ToString();
//使用臨時文件名
string URI = "FTP://" + hostname + "/" + targetDir + "/" + target;
///WebClient webcl = new WebClient();
System.Net.FtpWebRequest ftp = GetRequest(URI, username, password);
//設置FTP命令 設置所要執行的FTP命令,
//ftp.Method = System.Net.WebRequestMethods.Ftp.ListDirectoryDetails;//假設此處為顯示指定路徑下的文件列表
ftp.Method = System.Net.WebRequestMethods.Ftp.UploadFile;
//指定文件傳輸的數據類型
ftp.UseBinary = true;
ftp.UsePassive = true; //告訴ftp文件大小
ftp.ContentLength = fileinfo.Length;
//緩沖大小設置為2KB
const int BufferSize = 2048;
byte[] content = new byte[BufferSize - 1 + 1];
int dataRead; //打開一個文件流 (System.IO.FileStream) 去讀上傳的文件
using (FileStream fs = fileinfo.OpenRead())
{
try { //把上傳的文件寫入流
using (Stream rs = ftp.GetRequestStream())
{ do
{ //每次讀文件流的2KB
dataRead = fs.Read(content, 0, BufferSize); rs.Write(content, 0, dataRead); }
while (!(dataRead < BufferSize)); rs.Close(); } }
catch (Exception ex) { } finally { fs.Close(); } }
ftp = null; //設置FTP命令
ftp = GetRequest(URI, username, password);
ftp.Method = System.Net.WebRequestMethods.Ftp.Rename; //改名
ftp.RenameTo = fileinfo.Name; try { ftp.GetResponse(); }
catch (Exception ex)
{
ftp = GetRequest(URI, username, password); ftp.Method = System.Net.WebRequestMethods.Ftp.DeleteFile; //刪除
ftp.GetResponse(); throw ex; } finally
{
//fileinfo.Delete(); } // 可以記錄一個日誌 "上傳" + fileinfo.FullName + "上傳到" + "FTP://" + hostname + "/" + targetDir + "/" + fileinfo.Name + "成功." );
ftp = null;
#region
/***** *FtpWebResponse * ****/ //FtpWebResponse ftpWebResponse = (FtpWebResponse)ftp.GetResponse();
#endregion
}
/// <summary>
/// 下載文件
/// </summary>
/// <param name="localDir">下載至本地路徑</param>
/// <param name="FtpDir">ftp目標文件路徑</param>
/// <param name="FtpFile">從ftp要下載的文件名</param>
/// <param name="hostname">ftp地址即IP</param>
/// <param name="username">ftp用戶名</param>
/// <param name="password">ftp密碼</param>
public static void DownloadFile(string localDir, string FtpDir, string FtpFile, string hostname, string username, string password)
{
string URI = "FTP://" + hostname + "/" + FtpDir + "/" + FtpFile;
string tmpname = Guid.NewGuid().ToString();
string localfile = localDir + @"\" + tmpname;

System.Net.FtpWebRequest ftp = GetRequest(URI, username, password);
ftp.Method = System.Net.WebRequestMethods.Ftp.DownloadFile;
ftp.UseBinary = true;
ftp.UsePassive = false;

using (FtpWebResponse response = (FtpWebResponse)ftp.GetResponse())
{
using (Stream responseStream = response.GetResponseStream())
{
//loop to read & write to file
using (FileStream fs = new FileStream(localfile, FileMode.CreateNew))
{
try
{
byte[] buffer = new byte[2048];
int read = 0;
do
{
read = responseStream.Read(buffer, 0, buffer.Length);
fs.Write(buffer, 0, read);
} while (!(read == 0));
responseStream.Close();
fs.Flush();
fs.Close();
}
catch (Exception)
{
//catch error and delete file only partially downloaded
fs.Close();
//delete target file as it's incomplete
File.Delete(localfile);
throw;
}
}

responseStream.Close();
}

response.Close();
}

try
{
File.Delete(localDir + @"\" + FtpFile);
File.Move(localfile, localDir + @"\" + FtpFile);

ftp = null;
ftp = GetRequest(URI, username, password);
ftp.Method = System.Net.WebRequestMethods.Ftp.DeleteFile;
ftp.GetResponse();

}
catch (Exception ex)
{
File.Delete(localfile);
throw ex;
}

// 記錄日誌 "從" + URI.ToString() + "下載到" + localDir + @"\" + FtpFile + "成功." );
ftp = null;
}

/// <summary>
/// 搜索遠程文件
/// </summary>
/// <param name="targetDir"></param>
/// <param name="hostname"></param>
/// <param name="username"></param>
/// <param name="password"></param>
/// <param name="SearchPattern"></param>
/// <returns></returns>
public static List<string> ListDirectory(string targetDir, string hostname, string username, string password, string SearchPattern)
{
List<string> result = new List<string>();
try
{
string URI = "FTP://" + hostname + "/" + targetDir + "/" + SearchPattern;

System.Net.FtpWebRequest ftp = GetRequest(URI, username, password);
ftp.Method = System.Net.WebRequestMethods.Ftp.ListDirectory;
ftp.UsePassive = true;
ftp.UseBinary = true;

string str = GetStringResponse(ftp);
str = str.Replace("\r\n", "\r").TrimEnd('\r');
str = str.Replace("\n", "\r");
if (str != string.Empty)
result.AddRange(str.Split('\r'));

return result;
}
catch { }
return null;
}

private static string GetStringResponse(FtpWebRequest ftp)
{
//Get the result, streaming to a string
string result = "";
using (FtpWebResponse response = (FtpWebResponse)ftp.GetResponse())
{
long size = response.ContentLength;
using (Stream datastream = response.GetResponseStream())
{
using (StreamReader sr = new StreamReader(datastream, System.Text.Encoding.Default))
{
result = sr.ReadToEnd();
sr.Close();
}

datastream.Close();
}

response.Close();
}

return result;
}

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Net;

/// <summary>
/// 向Ftp伺服器上傳文件並創建和本地相同的目錄結構
/// 遍歷目錄和子目錄的文件
/// </summary>
/// <param name="file"></param>
private void GetFileSystemInfos(FileSystemInfo file)
{
string getDirecName=file.Name;
if (!ftpIsExistsFile(getDirecName, "192.168.0.172", "Anonymous", "") && file.Name.Equals(FileName))
{
MakeDir(getDirecName, "192.168.0.172", "Anonymous", "");
}
if (!file.Exists) return;
DirectoryInfo dire = file as DirectoryInfo;
if (dire == null) return;
FileSystemInfo[] files = dire.GetFileSystemInfos();

for (int i = 0; i < files.Length; i++)
{
FileInfo fi = files[i] as FileInfo;
if (fi != null)
{
DirectoryInfo DirecObj=fi.Directory;
string DireObjName = DirecObj.Name;
if (FileName.Equals(DireObjName))
{
UploadFile(fi, DireObjName, "192.168.0.172", "Anonymous", "");
}
else
{
Match m = Regex.Match(files[i].FullName, FileName + "+.*" + DireObjName);
//UploadFile(fi, FileName+"/"+DireObjName, "192.168.0.172", "Anonymous", "");
UploadFile(fi, m.ToString(), "192.168.0.172", "Anonymous", "");
}
}
else
{
string[] ArrayStr = files[i].FullName.Split('\\');
string finame=files[i].Name;
Match m=Regex.Match(files[i].FullName,FileName+"+.*"+finame);
//MakeDir(ArrayStr[ArrayStr.Length - 2].ToString() + "/" + finame, "192.168.0.172", "Anonymous", "");
MakeDir(m.ToString(), "192.168.0.172", "Anonymous", "");
GetFileSystemInfos(files[i]);
}
}
}

/// <summary>
/// 判斷ftp伺服器上該目錄是否存在
/// </summary>
/// <param name="dirName"></param>
/// <param name="ftpHostIP"></param>
/// <param name="username"></param>
/// <param name="password"></param>
/// <returns></returns>
private bool ftpIsExistsFile(string dirName, string ftpHostIP, string username, string password)
{
bool flag = true;
try
{
string uri = "ftp://" + ftpHostIP + "/" + dirName;
System.Net.FtpWebRequest ftp = GetRequest(uri, username, password);
ftp.Method = WebRequestMethods.Ftp.ListDirectory;

FtpWebResponse response = (FtpWebResponse)ftp.GetResponse();
response.Close();
}
catch (Exception )
{
flag = false;
}
return flag;
}

G. ftp文件傳送就是把文件從一台計算機轉移到另一台計算機上這句話對嗎為什麼

不對的,簡單點的解釋是:轉移相當於剪切,ftp的文件傳送相當於復制

H. 如何把建立在自己電腦上的ftp伺服器轉移到另一台電腦

在你對應的
/etc/vsftpd/vsftpd_user_conf 目錄下 ,把對應賬號的
local_root=/home/exchangeftp/edmp/ftpdata/34400001
local_root這個路徑改成另一個伺服器的 。

熱點內容
第三方雲伺服器怎麼用 發布:2024-10-10 02:12:45 瀏覽:398
php判斷文件是否上傳 發布:2024-10-10 02:11:18 瀏覽:58
mac如何連接列印伺服器 發布:2024-10-10 02:00:49 瀏覽:478
我的世界手機版0111伺服器 發布:2024-10-10 01:47:08 瀏覽:48
深圳編程培訓哪裡好 發布:2024-10-10 01:36:37 瀏覽:38
優享靈活配置怎麼樣 發布:2024-10-10 01:36:36 瀏覽:642
全球ip伺服器登錄 發布:2024-10-10 01:35:02 瀏覽:634
集群伺服器地址都是一樣的嗎 發布:2024-10-10 01:07:39 瀏覽:325
java怎麼開平方 發布:2024-10-10 01:02:25 瀏覽:486
windowsserver更新伺服器搭建 發布:2024-10-10 00:42:32 瀏覽:658