📄 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 + -