C#中的Java lib错误 [英] java lib error in c#
本文介绍了C#中的Java lib错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我使用带有C#代码的"java.util.zip"压缩文件时,我的代码抛出"java.io.File..ctor(字符串路径)错误".
谁能告诉我为什么在下面的代码中引发此错误
My code throws an error "at java.io.File..ctor(String path)" while I am compressing a file using "java.util.zip" with c# code.
Can any one tell me why this error is throw in below code
java.io.FileOutputStream fos = new java.io.FileOutputStream("c:\zip.zip"); // J# output
错误是:
"java.io.File"的类型初始值设定项引发异常"
The error is:
"The type initializer for ''java.io.File'' threw an exception"
推荐答案
您的字符串编码不正确,字符串中的反斜杠用于转义下一个字符,因此您的路径名中包含"\ z"以外的其他内容.它应该被编码为
Your string is incorrectly coded, the backslash in a string is used to escape the following character thus you have something other than "\z" in your path name. It should be coded as
"c:\\zip.zip"
或
or
@"c:\zip.zip"
这篇关于C#中的Java lib错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文