Skip to content

Commit

Permalink
Update FileHelper.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
laolarou726 committed Dec 4, 2024
1 parent cf8b0e4 commit 46d4062
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions ProjBobcat/ProjBobcat/Class/Helper/FileHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,22 @@ public static bool DeleteFileWithRetry(string filePath, int retryCount = 3)

return false;
}

public static bool MoveFileWithRetry(string oldPath, string newPath, int retryCount = 3)
{
ArgumentOutOfRangeException.ThrowIfLessThanOrEqual(retryCount, 0);

for (var i = 0; i < retryCount; i++)
try
{
File.Move(oldPath, newPath);
return true;
}
catch
{
// ignored
}

return false;
}
}

0 comments on commit 46d4062

Please sign in to comment.