有没有办法知道在调用之前调用TextReader.Read或TextReader.ReadToEnd调用会挂起而不抛出exeption?
try
{
using (var filterReader = new EPocalipse.IFilter.FilterReader(tempFileName))
{
mediaContent = filterReader.ReadToEnd();
}
}
catch (Exception e)
{
Log.Error("DealerPortalIndex Error on file: " + tempFileName, e, this);
mediaContent = string.Empty;
}
Run Code Online (Sandbox Code Playgroud)
filterReader.ReadToEnd()挂起并且永远不会在某个.xls文件上抛出异常(可能更多文件)
我也尝试使用filterReader.Read(char {},int,int)来读取块并获得相同的问题.
(您在代码中说textreader,但示例是使用EPocalips IFilter模块.)
我认为这是EPocalipse IFilter中的一个错误.我不知道他们的代码是如何更新的,但是在几年前我使用IFilters并使用EPocalipse代码时,我回想起了同样的效果.
您应该在调试器中运行它并破坏代码以查看它挂在EPocalipse库中的位置.很可能它陷入了循环.
[编辑]我找到了旧的更新代码并将其放在skydrive上(Epocalipse.IFilter.zip).看看它是否解决了你的问题.它具有无限IFilter解析循环的检测,以及具有锁定单元格的excel文件.