diff --git a/src/libraries/System.IO.FileSystem/tests/File/EncryptDecrypt.cs b/src/libraries/System.IO.FileSystem/tests/File/EncryptDecrypt.cs index 0c70a0406678cb..8aa5f73acb0bf9 100644 --- a/src/libraries/System.IO.FileSystem/tests/File/EncryptDecrypt.cs +++ b/src/libraries/System.IO.FileSystem/tests/File/EncryptDecrypt.cs @@ -71,7 +71,14 @@ public void EncryptDecrypt_Read() Assert.Equal(fileContentRead, File.ReadAllText(tmpFileName)); Assert.Equal(FileAttributes.Encrypted, (FileAttributes.Encrypted & File.GetAttributes(tmpFileName))); - File.Decrypt(tmpFileName); + // Sometimes Decrypt will fail with, eg., + // System.IO.IOException : The process cannot access the file '...' because it is being used by another process. + // Assumption is that it just needs a little more time + RetryHelper.Execute(() => + { + File.Decrypt(tmpFileName); + }, maxAttempts: 30, backoffFunc: null, retryWhen: e => e.GetType() == typeof(IOException)); + Assert.Equal(fileContentRead, File.ReadAllText(tmpFileName)); Assert.NotEqual(FileAttributes.Encrypted, (FileAttributes.Encrypted & File.GetAttributes(tmpFileName))); }