我必须在亚马逊 S3 中创建一个文件夹。现在必须将该文件夹转换为 zip 文件。我已使用 DotNetZip Liberary 转换为 .zip 文件。这是该链接
http://dotnetzip.codeplex.com/wikipage?title=CS-Examples
public void ConvertToZip(string directoryToZip, string zipFileName)
{
try
{
using (client = DisposableAmazonClient())
{
var sourDir = new S3DirectoryInfo(client, bucket, directoryToZip);
var destDir = new S3DirectoryInfo(client, bucket, CCUrlHelper.BackupRootFolderPhysicalPath);
using (var zip = new ZipFile())
{
zip.AddDirectory(sourDir.FullName); // recurses subdirectories
zip.Save(Path.Combine(destDir.FullName, zipFileName));
}
}
logger.Fatal("Successfully converted to Zip.");
}
catch (Exception ex)
{
logger.Error("Error while converting to zip. Error : " + ex.Message);
}
}
当我运行代码时,它显示错误“不支持给定路径的格式”。