Exemplo n.º 1
0
            /// <summary>
            /// Update Zip Comment
            /// Feature is supported in version 18.5 or greater of the API
            /// </summary>
            public static void UpdateComment()
            {
                try
                {
                    using (ZipFormat format = new ZipFormat(Common.MapSourceFilePath(filePath)))
                    {
                        format.ZipInfo.Comment = "test comment";

                        //Or you can update it using ZipFileComment Property
                        //format.ZipFileComment = "test comment";

                        format.Save(Common.MapDestinationFilePath(filePath));
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
            /// <summary>
            /// Removes comment in Zip file
            /// </summary>
            ///
            public static void RemoveComment()
            {
                try
                {
                    //ExStart:RemoveCommentZIPFile_17.12
                    // initialize
                    ZipFormat zipFormat = new ZipFormat(Common.MapSourceFilePath(filePath));

                    // remove user comment
                    zipFormat.RemoveFileComment();

                    // and commit changes
                    zipFormat.Save();
                    //ExEnd:RemoveCommentZIPFile_17.12
                }
                catch (Exception exp)
                {
                    Console.WriteLine(exp.Message);
                }
            }