0 votes
ago by (350 points)

I want to use Rebex.IO.ActionOnExistingFiles.Rename to rename duplicates but also need to set a custom 'CreationTime' of the file and without knowing its new name there appears to be no way of doing this?

I assume I would be best just checking the file exists before adding and doing this myself?

    using (var zip = new ZipArchive(zipFilename))
    {
        string archiveFilePath = "rename.txt";
        zip.AddFile(new MemoryStream(Encoding.UTF8.GetBytes("old file")), archiveFilePath, Rebex.IO.ActionOnExistingFiles.Rename);
        zip[archiveFilePath].CreationTime = DateTime.Now.AddMonths(-6);

        zip.AddFile(new MemoryStream(Encoding.UTF8.GetBytes("new file")), archiveFilePath, Rebex.IO.ActionOnExistingFiles.Rename);
        zip[archiveFilePath].CreationTime = DateTime.Now;
    }
Applies to: Rebex ZIP

Please log in or register to answer this question.

...