.net实现文件或目录复制到指定目录 及 压缩
private void CopyFile(string srcFile, string destDir)
{
DirectoryInfo destDirectory = new DirectoryInfo(destDir);
string fileName = Path.GetFileName(srcFile);
if (!File.Exists(srcFile))
{
return;
}
if (!destDirectory.Exists)
{
destDirectory.Create();
}
File.Copy(srcFile, destDirectory.FullName + @"\" + fileName, true);
}
复制引用https://www.cnblogs.com/jerry1999/p/4115867.html
压缩文件 引用using Ionic.Zip
using (ZipFile zip = new ZipFile(System.Text.Encoding.Default))
{
zip.AddDirectory(FilePath);
zip.Save(FilePath + ".zip");
}