The warning message you're encountering is related to a deprecation notice in the SharpZipLib library, specifically with how character encodings are handled for zip files. Here's a breakdown of the issue and how to address it:
Warning Message Explanation
-
ArcAIR.cs(92,17,92,45): This part of the message indicates the location in your code where the warning is occurring. Specifically, it points to a line and column range (from 17 to 45 on line 92) in your ArcAIR.cs file.
-
warning CS0618: This is a compiler warning code. CS0618 specifically indicates that a member (in this case, ZipStrings.CodePage) is obsolete.
-
'ZipStrings.CodePage' is obsolete: 'Use ZipFile/Zip*Stream StringCodec instead': This message tells you that the CodePage property of ZipStrings is no longer recommended for use. Instead, you should use StringCodec with ZipFile or Zip*Stream.
What's Happening
In older versions of SharpZipLib, you could set the code page for encoding and decoding strings within zip files using ZipStrings.CodePage. However, this approach has been largely superseded by more flexible and powerful encoding mechanisms through StringCodec.
How to Fix
To address this warning, you need to update your code to use the recommended approach:
-
Check if You're Using the Latest SharpZipLib: Ensure you're using a recent version of SharpZipLib. You can update via NuGet Package Manager.
-
Use StringCodec: When creating or using a ZipFile or streams like ZipInputStream/ZipOutputStream, you'll need to specify a StringCodec that defines how string data (like file names) should be encoded and decoded.
Here's a basic example of how you might set up a ZipFile with a specific encoding:
using (var zipFile = ZipFile.Create(new FileStream(zipPath, FileMode.Create)))
{
// Specify a codec that uses UTF8
zipFile.StringCodec = new Utf8StringCodec();
// ... rest of your code to add entries, etc.
}
public class Utf8StringCodec : IStringCodec
{
public byte[] Encode(string str)
{
return Encoding.UTF8.GetBytes(str);
}
public string Decode(byte[] bytes)
{
return Encoding.UTF8.GetString(bytes);
}
}
For streams:
using (var zipOutputStream = new ZipOutputStream(File.Create(zipPath)))
{
zipOutputStream.StringCodec = new Utf8StringCodec();
// ... rest of your code
}
Conclusion
By moving away from the deprecated ZipStrings.CodePage and towards using a StringCodec with your zip operations, you'll be using the recommended and likely more versatile approach for handling string encodings in SharpZipLib.