Tomek Melissa 2020-02-05 15:58:58 +01:00
Родитель 418b97e39c 8ae902d869
Коммит aa86239565
2 изменённых файлов: 14 добавлений и 8 удалений

Просмотреть файл

@ -34,16 +34,22 @@ namespace RecurringIntegrationsScheduler.Common.Helpers
/// </summary> /// </summary>
/// <param name="filePath">File path</param> /// <param name="filePath">File path</param>
/// <returns>Stream</returns> /// <returns>Stream</returns>
public static Stream Read(string filePath) public static Stream Read(string filePath, FileShare fileShare = FileShare.ReadWrite)
{ {
if (File.Exists(filePath)) if (File.Exists(filePath))
{ {
return new FileStream(filePath, try
FileMode.Open, {
FileAccess.ReadWrite, return new FileStream(filePath,
FileShare.ReadWrite, FileMode.Open,
4096, FileAccess.ReadWrite,
true); fileShare,
4096,
true);
}
catch (IOException)
{
}
} }
return null; return null;
} }

Просмотреть файл

@ -194,7 +194,7 @@ namespace RecurringIntegrationsScheduler.Job
} }
fileCount++; fileCount++;
var sourceStream = _retryPolicyForIo.Execute(() => FileOperationsHelper.Read(dataMessage.FullPath)); var sourceStream = _retryPolicyForIo.Execute(() => FileOperationsHelper.Read(dataMessage.FullPath, FileShare.None));
if (sourceStream == null) continue;//Nothing to do here if (sourceStream == null) continue;//Nothing to do here
sourceStream.Seek(0, SeekOrigin.Begin); sourceStream.Seek(0, SeekOrigin.Begin);