Home Forums .NET libraries Xceed Zip & Real-Time Zip for .NET Unzipping to a New File Name

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #19618 |

    I am new to Xceed, and am trying to duplicate existing ICSharp code that computes a new name for each compresse file in the zip file directory. I have the following C# code:

    DiskFolder DestinationFolder = new DiskFolder(DestPath);
    DiskFile zipFile = new DiskFile(FileName);
    ZipArchive zip = new ZipArchive(zipFile);

    AbstractFile[] FileList = zip.GetFiles(true,filters[0]);

    foreach (AbstractFile Ze in FileList)
    {
    string NewFileName = fn.makeNewFilename(Ze.Name);

    Ze.Name= NewFileName;
    Ze.CopyTo(DestinationFolder,false);
    }

    I am getting an error at the “Ze.Name= NewFileName;” step indicating that I do not have the rights to change this name. Am I misunderstanding the concept here? I have verified that the initial Ze.Name and NewFileName have the expected values. I assumed from the documentation that the name would be applied when the file was created. I didn’t see anywhere to request additional write permissions.

    Any help would be appreciated.

    Imported from legacy forums. Posted by fredr (had 2463 views)

    User (Old forums)
    Member
    Post count: 23064

    Create an AbstractFile with the name of the new file you want, and then use it to copy the zipped file to it :

    DiskFolder DestinationFolder = new DiskFolder(DestPath);
    DiskFile zipFile = new DiskFile(FileName);
    ZipArchive zip = new ZipArchive(zipFile);

    AbstractFile[] FileList = zip.GetFiles(true,filters[0]);

    foreach (AbstractFile Ze in FileList)
    {
    //string NewFileName = fn.makeNewFilename(Ze.Name);
    AbstractFile newFile = new DiskFile( DestinationFolder.Filename + Ze.Name )

    //Ze.Name= NewFileName;
    //Ze.CopyTo(DestinationFolder, false);
    Ze.CopyTo(newFile, true);
    }

    Imported from legacy forums. Posted by André (had 2995 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.