mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-04-17 05:59:39 +02:00
EnhancedFileSystemWatcher (#86)
This commit is contained in:
29
src/WireMock.Net/Util/FileHelper.cs
Normal file
29
src/WireMock.Net/Util/FileHelper.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
|
||||
namespace WireMock.Util
|
||||
{
|
||||
internal static class FileHelper
|
||||
{
|
||||
private const int NumberOfRetries = 3;
|
||||
private const int DelayOnRetry = 500;
|
||||
|
||||
public static string ReadAllText(string path)
|
||||
{
|
||||
for (int i = 1; i <= NumberOfRetries; ++i)
|
||||
{
|
||||
try
|
||||
{
|
||||
return File.ReadAllText(path);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// You may check error code to filter some exceptions, not every error can be recovered.
|
||||
Thread.Sleep(DelayOnRetry);
|
||||
}
|
||||
}
|
||||
|
||||
throw new IOException();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user