?? compareandoperate.cs
字號:
using System;
using System.Collections.Generic;
using System.Text;
namespace ftpTransport
{
class CompareAndOperate
{
/*類說明:
* 進行文件名比較,如果沒有就實現下載,
* 也就是均衡本地與遠程
* 遠程沒有本地文件名就上傳本地多的文件
* 本地沒有遠程的文件就下載遠程多的文件
*
*
*/
public CompareAndOperate()
{
}
//進行文件名比較,如果沒有就實現下載
public CompareAndOperate(string [] localFiles,string [] RemoteFiles)
{
string curLocalFile;
string curRemoteFile;
bool isRemoteFind = false;
bool isLocalFind = false;
//遍歷本地
for (int i = 0; i < localFiles.Length; i++)
{
curLocalFile = localFiles[i];
for (int j = 0; j < RemoteFiles.Length; j++)
{
if (curLocalFile == RemoteFiles[j])
{
isRemoteFind = true;
break;
}
}
if (!isRemoteFind)
{//本地文件遠程目錄中沒有
UploadFiles(curLocalFile,curLocalFile);
}
isRemoteFind = false;
}
//遍歷遠程
for (int i = 0; i < RemoteFiles.Length; i++)
{
curRemoteFile = RemoteFiles[i];
for (int j = 0; j < localFiles.Length; j++)
{
if (curRemoteFile == localFiles[j])
{
isLocalFind = true;
break;
}
}
if (!isLocalFind)
{
DownLoadFiles(curRemoteFile);
}
}
isLocalFind = false;
}
private void DownLoadFiles(string fileName)
{
ftpClient fc = new ftpClient();
fc.DownLoadFile(fileName);
}
private void UploadFiles(string fileName)
{
ftpClient fc = new ftpClient();
fc.UpLoadFile(fileName);
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -