我正在尝试使用ICSharpCode.SharpZiplib库生成一个Zip文件,但它会引起一个非常奇怪的错误.
码:
public static voID Zipfiles(string inputFolderPath,string outputPathAndfile,string password) { ArrayList ar = GeneratefileList(inputFolderPath); // generate file List int TrimLength = (Directory.GetParent(inputFolderPath)).ToString().Length; TrimLength += 1; //remove '\' fileStream ostream; byte[] obuffer; ZipOutputStream oZipStream = new ZipOutputStream(file.Create(outputPathAndfile)); // create zip stream if (password != null && password != String.Empty) oZipStream.Password = password; oZipStream.SetLevel(9); // maximum compression ZipEntry oZipEntry; foreach (string Fil in ar) // for each file,generate a zipentry { oZipEntry = new ZipEntry(Fil.Remove(0,TrimLength)); oZipStream.PutNextEntry(oZipEntry); if (!Fil.EndsWith(@"/")) // if a file ends with '/' its a directory { ostream = file.OpenRead(Fil); obuffer = new byte[ostream.Length]; ostream.Read(obuffer,obuffer.Length); oZipStream.Write(obuffer,obuffer.Length); } } oZipStream.Finish(); oZipStream.Close();}private static ArrayList GeneratefileList(string Dir){ ArrayList fils = new ArrayList(); bool Empty = true; foreach (string file in Directory.Getfiles(Dir,"*.xml")) // add each file in directory { fils.Add(file); Empty = false; } if (Empty) { if (Directory.GetDirectorIEs(Dir).Length == 0) // if directory is completely empty,add it { fils.Add(Dir + @"/"); } } foreach (string dirs in Directory.GetDirectorIEs(Dir)) // recursive { foreach (object obj in GeneratefileList(dirs)) { fils.Add(obj); } } return fils; // return file List}
错误:
Unhandled Exception: System.NotSupportedException: codepage 437 not supported at System.Text.EnCoding.GetEnCoding (Int32 codepage) [0x00000] in <filename unkNown>:0 at ICSharpCode.SharpZiplib.Zip.ZipConstants.ConvertToArray (System.String str) [0x00000] in <filename unkNown>:0 at ICSharpCode.SharpZiplib.Zip.ZipConstants.ConvertToArray (Int32 flags,System.String str) [0x00000] in <filename unkNown>:0 at ICSharpCode.SharpZiplib.Zip.ZipOutputStream.PutNextEntry (ICSharpCode.SharpZiplib.Zip.ZipEntry entry) [0x00000] in <filename unkNown>:0 at WpfPrototype1.MainInvoicesVIEw.Zipfiles (System.String inputFolderPath,System.String outputPathAndfile,System.String password) [0x00000] in <filename unkNown>:0 at WpfPrototype1.MainInvoicesVIEw.<VIEwDIDLoad>m__6 (System.Object,System.EventArgs ) [0x00000] in <filename unkNown>:0 at Monotouch.UIKit.UIControlEventProxy.Activated () [0x00000] in <filename unkNown>:0 at (wrapper managed-to-native) Monotouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr) at Monotouch.UIKit.UIApplication.Main (System.String[] args,System.String principalClassname,System.String delegateClassname) [0x00000] in <filename unkNown>:0 at Monotouch.UIKit.UIApplication.Main (System.String[] args) [0x00000] in <filename unkNown>:0 at WpfPrototype1.Application.Main (System.String[] args) [0x00000] in <filename unkNown>:0
如何使代码支持codepage 437?
问候,
克劳迪奥
>单击Project-> [Projectname]选项
>选择iPhone Build
>你现在有两个选择
一个.从I18n装配体列表中选择“西”
湾将“-i18n =西”添加到“额外参数”
注意:对于配置和平台的每个组合,您都需要执行步骤3.
总结以上是内存溢出为你收集整理的Monotouch – ICSharpCode.SharpZipLib给出错误全部内容,希望文章能够帮你解决Monotouch – ICSharpCode.SharpZipLib给出错误所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)