Home Forums .NET libraries Xceed Zip & Real-Time Zip for .NET Change zippedFile comment

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

    Hi,

    i want to insert a file into a new zip and change the zippedfile property “comment”.
    Someone knows how i can do it?

    thanks in advance, Marcelo.

    Imported from legacy forums. Posted by Marcelo (had 3294 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi, me again.

    Fyi i use this code, but doesn’t work.

    Dim ZipArch As New Xceed.Zip.ZipArchive(New DiskFile(ZipFileName))
    ZipArch.DefaultEncryptionPassword = ZipPasswd
    ZipArch.DefaultDecryptionPassword = ZipPasswd
    Dim NewFile As New DiskFile(Filename)
    Dim DestFolder As AbstractFolder = ZipArch.GetFolder(“\”)
    NewFile.CopyTo(FSevents, Nothing, DestFolder, ReplaceIfExists)
    If FileComment <> “” Then
    Dim ZipContentFile As Xceed.Zip.ZippedFile
    ZipContentFile = ZipArch.GetFile(Filename)
    ZipArch.BeginUpdate()
    ZipContentFile.Comment = FileComment
    ZipArch.EndUpdate()

    ZipContentFile.Refresh()
    End If

    Thanks, Marcelo

    Imported from legacy forums. Posted by Marcelo (had 241 views)

    User (Old forums)
    Member
    Post count: 23064

    This should work. I just tested it here, and it worked fine.
    <i>
    AbstractFile zip = new DiskFile( @”D:\\temp.zip” );
    ZipArchive archive = new ZipArchive( zip );

    ZippedFile file = new ZippedFile( zip, “tempfile.txt”);

    file.Comment = “test comment”;
    Console.WriteLine( file.Comment.ToString() );
    </i>
    If I run this code twice, the second time commenting out the file.Comment line, “test comment” is displayed, which means the comment was saved in the archive.

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

    User (Old forums)
    Member
    Post count: 23064

    Thanks! it works.

    i review my code and found that the variable Filename has the path of the file.

    Thanks again, Marcelo.

    Imported from legacy forums. Posted by Marcelo (had 4020 views)

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