C#异常 [英] C# exception

查看:77
本文介绍了C#异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有Windows(wordnet api),它会在按钮单击中加载

Hi,
I have windows (wordnet api) which is load in button click

frmWordnetAPI relatedWords = new frmWordnetAPI();
relatedWords.ShowDialog();


该API从(源文件)目录获取一些数据.在第一个按钮中编译程序时,单击该窗体可以完美加载,但是当我关闭API并重新单击该按钮以进行加载时,将引发异常,表明
The process cannot access the file ''D:\MIT\project\wordnet API\TestApplication\WNdb-3.0\dict\index.adj'' because it is being used by another process.

以下代码引发异常


This API is getting some data from (source file) directory. When compling the program in first button click the form is loading perfectly, but when I close API and re click the button to load it is throwing an exception saying that
The process cannot access the file ''D:\MIT\project\wordnet API\TestApplication\WNdb-3.0\dict\index.adj'' because it is being used by another process.

The following code is throwing an exception

BinarySearchTextStream searchStream = new BinarySearchTextStream(indexPath, new BinarySearchTextStream.SearchComparisonDelegate(delegate(string searchWord, string currentLine)
{
    // if we landed on the header text, search further down
    if (currentLine[0] == '' '')
        return 1;
    string currentWord = currentLine.Substring(0, currentLine.IndexOf('' ''));
    return searchWord.CompareTo(currentWord);
}));


请帮助

推荐答案

也许您忘记了关闭文件(线程可能仍将其保持打开状态,而您没有正确终止该线程?). br/>
确保您的应用仍未运行(使用任务管理器).
Maybe you forgot to close the file (a thread might still be holding it open, and you didn''t properly terminate the thread?).

Make sure your app isn''t still running (use Task Manager).


这篇关于C#异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆