diff --git a/src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs b/src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs index fa4c09401..ecc937554 100644 --- a/src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs +++ b/src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs @@ -1579,7 +1579,7 @@ private void AddUpdate(ZipUpdate update) { contentsEdited_ = true; - int index = FindExistingUpdate(update.Entry.Name); + int index = FindExistingUpdate(update.Entry); if (index >= 0) { @@ -2489,7 +2489,9 @@ private int FindExistingUpdate(string fileName) { int result = -1; - string convertedName = GetTransformedFileName(fileName); + string convertedName = IsDirectoryName(fileName) + ? GetTransformedDirectoryName(fileName) + : GetTransformedFileName(fileName); if (updateIndex_.ContainsKey(convertedName)) { @@ -2511,6 +2513,15 @@ private int FindExistingUpdate(string fileName) return result; } + private bool IsDirectoryName(string name) + { + int nameLength = name.Length; + bool result = + ((nameLength > 0) && + ((name[nameLength - 1] == '/') || (name[nameLength - 1] == '\\'))); + return result; + } + /// /// Get an output stream for the specified ///