📌  相关文章
📜  该进程无法访问该文件,因为它正被另一个进程使用. c# 代码示例

📅  最后修改于: 2022-03-11 14:48:59.781000             🧑  作者: Mango

代码示例1
private const int NumberOfRetries = 3;
private const int DelayOnRetry = 1000;

for (int i=1; i <= NumberOfRetries; ++i) {
    try {
        // Do stuff with file
        break; // When done we can break loop
    }
    catch (IOException e) when (i <= NumberOfRetries) {
        // You may check error code to filter some exceptions, not every error
        // can be recovered.
        Thread.Sleep(DelayOnRetry);
    }
}