本文整理汇总了C#中Ionic.Zip.ZipFile.AddDirectoryByName方法的典型用法代码示例。如果您正苦于以下问题:C# ZipFile.AddDirectoryByName方法的具体用法?C# ZipFile.AddDirectoryByName怎么用?C# ZipFile.AddDirectoryByName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ionic.Zip.ZipFile
的用法示例。
在下文中一共展示了ZipFile.AddDirectoryByName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateEPUB
public static void GenerateEPUB(string inputFile, string outputFile, ConversionOptions options)
{
ZipFile file = new ZipFile(outputFile);
//generate mimetype
using (Stream mime = new MemoryStream())
{
byte[] mimeBytes = System.Text.Encoding.ASCII.GetBytes(_mimetype);
mime.Write(mimeBytes, 0, mimeBytes.Length);
file.AddEntry("mimetype", mime);
}
//generate META-INF
file.AddDirectoryByName("META-INF");
{
//container.xml
using (Stream container = new MemoryStream())
{
byte[] containerBytes = System.Text.Encoding.ASCII.GetBytes(Crabwise.PDFtoEPUB.Properties.Resources.container);
container.Write(containerBytes, 0, containerBytes.Length);
file.AddEntry("META-INF\\container.xml", container);
}
}
//generate OEBPS
file.AddDirectoryByName("OEBPS");
{
//images
file.AddDirectoryByName("OEBPS\\IMAGES");
{
//add each image to the directory
}
//xhtml chapters
//page-template.xpgt
byte[] pagetemplateBytes = System.Text.Encoding.ASCII.GetBytes(Properties.Resources.page_template);
file.AddEntry("OEBPS\\page-template.xpgt", pagetemplateBytes);
//stylesheet.css
byte[] stylesheetBytes = System.Text.Encoding.ASCII.GetBytes(Properties.Resources.stylesheet);
file.AddEntry("OEBPS\\stylesheet.css", stylesheetBytes);
//title_page.xhtml
file.AddEntry("OEBPS\\title_page.xhtml", TitlePageGenerator.GetTitlePage(options));
//Content.opf
file.AddEntry("OEBPS\\content.opf", ContentFileGenerator.GetContentFile(options));
//toc.ncx
file.AddEntry("OEBPS\\toc.ncx", TOCFileGenerator.GetTOCFile(options));
}
}
示例2: GetPages
public FileResult GetPages()
{
if (Request.Url != null)
{
var zip = new ZipFile();
zip.AddDirectoryByName("Content");
zip.AddDirectory(Server.MapPath("~/Content/"), "Content");
var paths = DtoHelper.GetPaths();
foreach (var path in paths)
{
var url = Url.Action(path.Action, path.Controller, null, Request.Url.Scheme);
if (url != null)
{
var request = WebRequest.Create(string.Concat(url, Constants.Resources.DownloadParameter));
request.Credentials = CredentialCache.DefaultCredentials;
var response = (HttpWebResponse)request.GetResponse();
var dataStream = response.GetResponseStream();
{
if (dataStream != null)
{
zip.AddEntry(path.FileName, dataStream);
}
}
}
}
var stream = new MemoryStream();
zip.Save(stream);
stream.Position = 0;
return new FileStreamResult(stream, "application/zip") { FileDownloadName = Constants.Resources.DownloadName };
}
return null;
}
示例3: Save
/// <summary>
/// Save a Package in to Filesystem
/// </summary>
/// <param name="filename">Suggested Extension: .xpkg</param>
/// <param name="pkg">The saving Package</param>
public static void Save(string filename, Package pkg)
{
using(var z = new ZipFile())
{
var content = z.AddDirectoryByName("content");
var res = z.AddDirectoryByName("res");
foreach (var r in pkg.XamlFiles)
{
z.AddEntry($"content/{r.Key}", r.Value);
}
foreach (var r in pkg.Ressources)
{
z.AddEntry($"res/{r.Key}", r.Value);
}
z.AddEntry("meta.xaml", XamlServices.Save(pkg.Meta));
z.Save(filename);
}
}
示例4: CreateZipFile
public static ZipFile CreateZipFile(string path, ZipFile zip, List<Attachment> files, string userName)
{
//var zip = new ZipFile(Encoding.UTF8);
zip.AddDirectoryByName(userName);
foreach (var fileName in files)
{
if (File.Exists(path + fileName.PathName + "//" + fileName.FileName))
{
zip.AddFile(path + fileName.PathName + "//" + fileName.FileName, userName).FileName = "\\" + userName + "\\" + fileName.Name;
}
}
return zip;
}
示例5: WriteSessionArchive
/// <summary>
/// Writes a Fiddler session to SAZ.
/// Written by Eric Lawrence (http://www.ericlawrence.com)
/// THIS CODE SAMPLE & SOFTWARE IS LICENSED "AS-IS." YOU BEAR THE RISK OF USING IT. MICROSOFT GIVES NO EXPRESS WARRANTIES, GUARANTEES OR CONDITIONS.
/// </summary>
/// <param name="sFilename"></param>
/// <param name="arrSessions"></param>
/// <param name="sPassword"></param>
/// <returns></returns>
public static bool WriteSessionArchive(string sFilename, Session[] arrSessions, string sPassword)
{
const string S_VER_STRING = "2.8.9";
if ((null == arrSessions || (arrSessions.Length < 1))) {
return false;
}
try {
if (File.Exists(sFilename)) {
File.Delete(sFilename);
}
using (var oZip = new ZipFile()) {
oZip.AddDirectoryByName("raw");
if (!String.IsNullOrEmpty(sPassword)) {
if (CONFIG.bUseAESForSAZ) {
oZip.Encryption = EncryptionAlgorithm.WinZipAes256;
}
oZip.Password = sPassword;
}
oZip.Comment = "FiddlerCore SAZSupport (v" + S_VER_STRING + ") Session Archive. See http://www.fiddler2.com";
int iFileNumber = 1;
foreach (var oSession in arrSessions) {
var delegatesCopyOfSession = oSession;
string sBaseFilename = @"raw\" + iFileNumber.ToString("0000");
string sRequestFilename = sBaseFilename + "_c.txt";
string sResponseFilename = sBaseFilename + "_s.txt";
string sMetadataFilename = sBaseFilename + "_m.xml";
oZip.AddEntry(sRequestFilename, (sn, strmToWrite) => delegatesCopyOfSession.WriteRequestToStream(false, true, strmToWrite));
oZip.AddEntry(sResponseFilename, (sn, strmToWrite) => delegatesCopyOfSession.WriteResponseToStream(strmToWrite, false));
oZip.AddEntry(sMetadataFilename, (sn, strmToWrite) => delegatesCopyOfSession.WriteMetadataToStream(strmToWrite));
iFileNumber++;
}
oZip.Save(sFilename);
}
return true;
} catch (Exception) {
return false;
}
}
示例6: AddScripts
private void AddScripts(ZipFile zip, InputAction inputAction)
{
foreach (var scriptSequenceItem in inputAction.ScriptSequences)
{
var inputScript =
scriptProvider.Scripts.FirstOrDefault(s => s.Name == scriptSequenceItem.ScriptName);
if (inputScript == null)
continue;
zip.AddDirectoryByName(KeySndrApp.ScriptsFolderName + "\\Sources");
foreach (var sourceFile in inputScript.SourceFiles)
{
zip.AddEntry(KeySndrApp.ScriptsFolderName + "\\Sources\\" + sourceFile.FileName, sourceFile.Contents);
}
zip.AddEntry(KeySndrApp.ScriptsFolderName + "\\" + inputScript.FileName, JsonSerializer.Serialize(inputScript));
}
}
示例7: DownloadLocal
public void DownloadLocal(HttpProcessor p)
{
try
{
p.writeSuccess("application/octet-stream");
p.outputStreamWriter.WriteLine("Content-Disposition: attachment;filename=\"test.mxf\"");
Console.WriteLine(": Start transfer file");
long total = 0;
//String fileName = p.httpHeaders["X-File-Name"].ToString();
FileInfo fi = new FileInfo("C:/0003QS.MXF");
if (!fi.Exists)
{
throw new Exception("File not found");
}
long contentSize = fi.Length;
using (ZipFile zip = new ZipFile())
{
zip.UseZip64WhenSaving = Zip64Option.Always;
zip.AlternateEncodingUsage = ZipOption.AsNecessary;
ZipEntry files = zip.AddDirectoryByName("Files");
zip.AddEntry("Files/0002D000.MXF", new FileStream("C:/0002D000.MXF", FileMode.Open, FileAccess.Read));
zip.AddEntry("Files/0002D002.MXF", new FileStream("C:/0002D000.MXF", FileMode.Open, FileAccess.Read));
zip.Save(p.outputStream);
}
//FileStream stream = new FileStream("C:/0003QS.MXF", FileMode.Open, FileAccess.Read);
//byte[] buf = new byte[BUF_SIZE];
//int numread = stream.Read(buf, 0,BUF_SIZE);
//while (numread > 0 && contentSize>0)
//{
// p.outputStream.Write(buf, 0, numread);
// total += numread;
// contentSize -= numread;
// numread = stream.Read(buf, 0, (int)Math.Min(contentSize,BUF_SIZE));
//}
Console.WriteLine(": Completed transfer file. " + total);
//p.outputStreamWriter.WriteLine("{\"Status\":\"Success\",\"Size\":" + total + "}");
}
catch (Exception ex)
{
Console.WriteLine(": Error transfer file. ");
p.writeSuccess();
p.outputStreamWriter.WriteLine("{\"Status\":\"Failed\",\"Message\":\"" + ex.Message + "\"}");
}
}
示例8: DownloadFiles
protected void DownloadFiles(object sender, EventArgs e)
{
using (ZipFile zip = new ZipFile())
{
zip.AlternateEncodingUsage = ZipOption.AsNecessary;
zip.AddDirectoryByName("Files");
foreach (GridViewRow row in GridView1.Rows)
{
if ((row.FindControl("chkSelect") as CheckBox).Checked)
{
string filePath = (row.FindControl("lblFilePath") as Label).Text;
zip.AddFile(filePath, "Files");
}
}
Response.Clear();
Response.BufferOutput = false;
string zipName = String.Format("Zip_{0}.zip", DateTime.Now.ToString("yyyy-MMM-dd-HHmmss"));
Response.ContentType = "application/zip";
Response.AddHeader("content-disposition", "attachment; filename=" + zipName);
zip.Save(Response.OutputStream);
Response.End();
}
}
示例9: Solutions
public ZipFileResult Solutions(int id, bool compete)
{
var contest = this.Data.Contests.GetById(id);
var problems = contest.Problems.OrderBy(x => x.Name).ToList();
var participants =
this.Data.Participants.All()
.Where(x => x.ContestId == id && x.IsOfficial == compete)
.Select(
x => new { x.Id, x.User.UserName, x.User.UserSettings.FirstName, x.User.UserSettings.LastName, })
.ToList()
.OrderBy(x => x.UserName);
// Prepare file comment
var fileComment = new StringBuilder();
fileComment.AppendLine(string.Format("{1} submissions for {0}", contest.Name, compete ? "Contest" : "Practice"));
fileComment.AppendLine(string.Format("Number of participants: {0}", participants.Count()));
fileComment.AppendLine();
fileComment.AppendLine("Problems:");
foreach (var problem in problems)
{
fileComment.AppendLine(
string.Format(
"{0} - {1} points, time limit: {2:0.000} sec., memory limit: {3:0.00} MB",
problem.Name,
problem.MaximumPoints,
problem.TimeLimit / 1000.0,
problem.MemoryLimit / 1024.0 / 1024.0));
}
// Prepare zip file
var file = new ZipFile
{
Comment = fileComment.ToString(),
AlternateEncoding = Encoding.UTF8,
AlternateEncodingUsage = ZipOption.AsNecessary
};
// Add participants solutions
foreach (var participant in participants)
{
// Create directory with the participants name
var directoryName =
string.Format("{0} ({1} {2})", participant.UserName, participant.FirstName, participant.LastName)
.ToValidFilePath();
var directory = file.AddDirectoryByName(directoryName);
foreach (var problem in problems)
{
// Find submission
var bestSubmission =
this.Data.Submissions.All()
.Where(
submission =>
submission.ParticipantId == participant.Id && submission.ProblemId == problem.Id)
.OrderByDescending(submission => submission.Points)
.ThenByDescending(submission => submission.Id)
.FirstOrDefault();
// Create file if submission exists
if (bestSubmission != null)
{
var fileName =
string.Format("{0}.{1}", problem.Name, bestSubmission.SubmissionType.FileNameExtension)
.ToValidFileName();
byte[] content;
if (bestSubmission.IsBinaryFile)
{
content = bestSubmission.Content;
}
else
{
content = bestSubmission.ContentAsString.ToByteArray();
}
var entry = file.AddEntry(string.Format("{0}\\{1}", directoryName, fileName), content);
entry.CreationTime = bestSubmission.CreatedOn;
entry.ModifiedTime = bestSubmission.CreatedOn;
}
}
}
// Send file to the user
var zipFileName = string.Format("{1} submissions for {0}.zip", contest.Name, compete ? "Contest" : "Practice");
return new ZipFileResult(file, zipFileName);
}
示例10: _Internal_Streams_ZipInput_Encryption
public void _Internal_Streams_ZipInput_Encryption(int fodderOption, int fileReadOption)
{
byte[] buffer = new byte[2048];
int n;
int[] fileCounts = { 1,
2,
_rnd.Next(8) + 6,
_rnd.Next(18) + 16,
_rnd.Next(48) + 56 };
for (int m = 0; m < fileCounts.Length; m++)
{
string password = TestUtilities.GenerateRandomPassword();
string dirToZip = String.Format("trial{0:D2}", m);
if (!Directory.Exists(dirToZip)) Directory.CreateDirectory(dirToZip);
int fileCount = fileCounts[m];
TestContext.WriteLine("=====");
TestContext.WriteLine("Trial {0} filecount={1}", m, fileCount);
var files = (new Func<string[]>( () => {
if (fodderOption == 0)
{
// zero length files
var a = new string[fileCount];
for (int i = 0; i < fileCount; i++)
a[i] = CreateZeroLengthFile(i, dirToZip);
return a;
}
if (fodderOption == 1)
return TestUtilities.GenerateFilesFlat(dirToZip, fileCount, 100, 72000);
// mixed = some zero and some not
var b = new string[fileCount];
for (int i = 0; i < fileCount; i++)
{
if (_rnd.Next(3) == 0)
b[i] = CreateZeroLengthFile(i, dirToZip);
else
{
b[i] = Path.Combine(dirToZip, String.Format("nonzero{0:D4}.txt", i));
TestUtilities.CreateAndFillFileText(b[i], _rnd.Next(60000) + 100);
}
}
return b;
}))();
for (int i = 0; i < crypto.Length; i++)
{
EncryptionAlgorithm c = crypto[i];
string zipFileToCreate =
Path.Combine(TopLevelDir,
String.Format("ZIS_Crypto.{0}.count.{1:D2}.{2}.zip",
c.ToString(), fileCounts[m], fodderOption));
// Create the zip archive
using (var zip = new ZipFile())
{
zip.Password = password;
zip.Encryption = c;
if (fodderOption > 2)
{
zip.AddDirectoryByName("subdir");
zip.AddDirectory(dirToZip, "subdir");
}
else
zip.AddDirectory(dirToZip);
zip.Save(zipFileToCreate);
}
// Verify the number of files in the zip
Assert.AreEqual<int>(TestUtilities.CountEntries(zipFileToCreate), files.Length,
"Incorrect number of entries in the zip file.");
// extract the files
string extractDir = String.Format("extract{0:D2}.{1:D2}", m, i);
TestContext.WriteLine("Extract to: {0}", extractDir);
Directory.CreateDirectory(extractDir);
var input = (new Func<ZipInputStream>( () => {
if (fileReadOption == 0)
{
var raw = File.OpenRead(zipFileToCreate);
return new ZipInputStream(raw);
}
return FileSystemZip.CreateInputStream(zipFileToCreate);
}))();
using (input)
{
// set password if necessary
if (crypto[i] != EncryptionAlgorithm.None)
//.........这里部分代码省略.........
示例11: zipFolder
private void zipFolder(CloudBlobClient blobClient, string basePrefix, string folderName, string zipDir, ref ZipFile zipFile)
{
zipDir = string.IsNullOrEmpty(zipDir) ? folderName : zipDir + "/" + folderName;
zipFile.AddDirectoryByName(zipDir);
var folderPrefix = basePrefix + StorageNamesEncoder.EncodeBlobName(folderName) + "/";
var blobs = blobClient.ListBlobsWithPrefix(folderPrefix,
new BlobRequestOptions() { BlobListingDetails = Microsoft.WindowsAzure.StorageClient.BlobListingDetails.Metadata, UseFlatBlobListing = false });
foreach (var blob in blobs)
{
if (blob is CloudBlobDirectory)
{
var dir = blob as CloudBlobDirectory;
var names = dir.Uri.ToString().Split('/');
for (var i = names.Length - 1; i >= 0; i--)
{
if (!string.IsNullOrEmpty(names[i]))
{
zipFolder(blobClient, folderPrefix, StorageNamesEncoder.DecodeBlobName(names[i]), zipDir, ref zipFile);
break;
}
}
}
if (blob is CloudBlob)
{
var cloudBlob = blob as CloudBlob;
var subStr = cloudBlob.Uri.ToString().Substring(cloudBlob.Uri.ToString().IndexOf(folderPrefix) + folderPrefix.Length);
var index = subStr.LastIndexOf('/');
if (index < 0)
{
index = 0;
}
var subFolderName = subStr.Substring(0, index);
var fileName = subStr.Substring(index);
var bytes = cloudBlob.DownloadByteArray();
if (!string.IsNullOrEmpty(subFolderName))
{
zipFile.AddDirectoryByName(zipDir + "/" + StorageNamesEncoder.DecodeBlobName(subFolderName));
}
zipFile.AddEntry(zipDir + "/" + StorageNamesEncoder.DecodeBlobName(subStr), bytes);
}
}
}
示例12: Password_UnsetEncryptionAfterSetPassword_wi13909_ZF
public void Password_UnsetEncryptionAfterSetPassword_wi13909_ZF()
{
// Verify that unsetting the Encryption property after
// setting a Password results in no encryption being used.
// This method tests ZipFile.
string unusedPassword = TestUtilities.GenerateRandomPassword();
int numTotalEntries = _rnd.Next(46)+653;
string zipFileToCreate = "UnsetEncryption.zip";
using (var zip = new ZipFile())
{
zip.Password = unusedPassword;
zip.Encryption = EncryptionAlgorithm.None;
for (int i=0; i < numTotalEntries; i++)
{
if (_rnd.Next(7)==0)
{
string entryName = String.Format("{0:D5}", i);
zip.AddDirectoryByName(entryName);
}
else
{
string entryName = String.Format("{0:D5}.txt", i);
if (_rnd.Next(12)==0)
{
var block = TestUtilities.GenerateRandomAsciiString() + " ";
string contentBuffer = String.Format("This is the content for entry {0}", i);
int n = _rnd.Next(6) + 2;
for (int j=0; j < n; j++)
contentBuffer += block;
byte[] buffer = System.Text.Encoding.ASCII.GetBytes(contentBuffer);
zip.AddEntry(entryName, contentBuffer);
}
else
zip.AddEntry(entryName, Stream.Null);
}
}
zip.Save(zipFileToCreate);
}
BasicVerifyZip(zipFileToCreate);
}
示例13: Download
public ActionResult Download(int? id)
{
//string path = HttpContext.Server.MapPath("~/DOCS/");
try
{
var list = new GedEntities().DOCUMENTOS.Where(d => d.DOC_PROC_ID == id).ToList();
if (list.Count == 0)
{
throw new Exception("Não existe documentos para download.");
}
using (ZipFile zip = new ZipFile())
{
zip.AlternateEncodingUsage = ZipOption.AsNecessary;
//zip.AddDirectoryByName("Files");
zip.AddDirectoryByName("DOCS_" + id.ToString());
foreach (var doc in list)
{
// Get every file size
//byte[] fileBytes = System.IO.File.ReadAllBytes(Server.MapPath("~/DOCS/"+doc.DOC_ARQUIVO));
// Get every file path
string filePath = Server.MapPath("~/DOCS/" + doc.DOC_ARQUIVO);
//zip.AddFile(filePath, "Files");
zip.AddFile(filePath, "DOCS_" + id.ToString());
}
Response.Clear();
Response.BufferOutput = false;
//string zipName = String.Format("Zip_{0}.zip", DateTime.Now.ToString("yyyy-MMM-dd-HHmmss"));
string zipName = String.Format("Zip_DOCS_{0}.zip", id.ToString());
Response.ContentType = "application/zip";
Response.AddHeader("content-disposition", "attachment; filename=" + zipName);
zip.Save(Response.OutputStream);
Response.End();
}
}
catch(Exception ex)
{
TempData["MsgErro"] = "Erro, " + ex.Message;
}
return RedirectToAction("Documentos", new { procID=id });
}
示例14: Test_AddDirectoryByName
public void Test_AddDirectoryByName()
{
for (int n = 1; n <= 10; n++)
{
var dirsAdded = new System.Collections.Generic.List<String>();
string zipFileToCreate = Path.Combine(TopLevelDir, String.Format("Test_AddDirectoryByName{0:N2}.zip", n));
using (ZipFile zip1 = new ZipFile())
{
for (int i = 0; i < n; i++)
{
// create an arbitrary directory name, add it to the zip archive
string dirName = TestUtilities.GenerateRandomName(24);
zip1.AddDirectoryByName(dirName);
dirsAdded.Add(dirName + "/");
}
zip1.Save(zipFileToCreate);
}
int dirCount = 0;
using (ZipFile zip2 = FileSystemZip.Read(zipFileToCreate))
{
foreach (var e in zip2)
{
TestContext.WriteLine("dir: {0}", e.FileName);
Assert.IsTrue(dirsAdded.Contains(e.FileName), "Cannot find the expected entry");
Assert.IsTrue(e.IsDirectory);
dirCount++;
}
}
Assert.AreEqual<int>(n, dirCount);
}
}
示例15: Extended_CheckZip2
public void Extended_CheckZip2()
{
string textToEncode =
"Pay no attention to this: " +
"We've read in the regular entry header, the extra field, and any " +
"encryption header. The pointer in the file is now at the start of " +
"the filedata, which is potentially compressed and encrypted. Just " +
"ahead in the file, there are _CompressedFileDataSize bytes of " +
"data, followed by potentially a non-zero length trailer, " +
"consisting of optionally, some encryption stuff (10 byte MAC for " +
"AES), and then the bit-3 trailer (16 or 24 bytes). " +
" " +
"The encryption can be either PKZIP 2.0 (weak) encryption, or " +
"WinZip-compatible AES encryption, which is considered to be " +
"strong and for that reason is preferred. In the WinZip AES " +
"option, there are two different keystrengths supported: 128 bits " +
"and 256 bits. " +
" " +
"The extra field, which I mentioned previously, specifies " +
"additional metadata about the entry, which is strictly-speaking, " +
"optional. These data are things like high-resolution timestamps, " +
"data sizes that exceed 2^^32, and other encryption " +
"possibilities. In each case the library that reads a zip file " +
"needs to be able to correctly deal with the various fields, " +
"validating the values within them. " +
" " +
"Now, cross all that with the variety of usage patterns - creating a " +
"zip, or reading, or extracting, or updating, or updating several " +
"times. And also, remember that the metadata may change during " +
"updates: an application can apply a password where none was used " +
"previously, or it may wish to remove an entry from the zip entirely. " +
" " +
"The huge variety of combinations of possibilities is what makes " +
"testing a zip library so challenging. " ;
string fileToZip = Path.Combine(SourceDir, TestUtilities.GetBinDir("Zip.Portable.Tests"), "Zip.Portable.dll");
for (int i = 0; i < crypto.Length; i++)
{
for (int j = 0; j < z64.Length; j++)
{
string zipFile = String.Format("Extended-CheckZip2-{0}.{1}.zip", i, j);
string password = Path.GetRandomFileName();
TestContext.WriteLine("=================================");
TestContext.WriteLine("Creating {0}...", Path.GetFileName(zipFile));
string dir = Path.GetRandomFileName();
using (var zip = new ZipFile())
{
zip.Comment = String.Format("Encryption={0} Zip64={1} pw={2}",
crypto[i].ToString(), z64[j].ToString(), password);
zip.Encryption = crypto[i];
if (crypto[i] != EncryptionAlgorithm.None)
{
TestContext.WriteLine("Encryption({0}) Zip64({1}) pw({2})",
crypto[i].ToString(), z64[j].ToString(), password);
zip.Password = password;
}
else
TestContext.WriteLine("Encryption({0}) Zip64({1})",
crypto[i].ToString(), z64[j].ToString());
zip.UseZip64WhenSaving = z64[j];
int N = _rnd.Next(11) + 5;
for (int k = 0; k < N; k++)
zip.AddDirectoryByName(Path.GetRandomFileName());
zip.AddEntry("File1.txt", textToEncode);
zip.AddFile(fileToZip, Path.GetRandomFileName());
zip.Save(zipFile);
}
BasicVerifyZip(zipFile, password, false);
TestContext.WriteLine("Checking zip...");
using (var sw = new StringWriter())
{
bool result = FileSystemZip.CheckZip(zipFile, false, sw);
Assert.IsTrue(result, "Zip ({0}) does not check OK", zipFile);
var msgs = sw.ToString().Split('\n');
foreach (var msg in msgs)
TestContext.WriteLine("{0}", msg);
}
TestContext.WriteLine("OK");
TestContext.WriteLine("");
}
}
}