diff --git a/src/libraries/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeFileHandle.Windows.cs b/src/libraries/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeFileHandle.Windows.cs index 3d5f8d22db02ba..d28602161b8f05 100644 --- a/src/libraries/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeFileHandle.Windows.cs +++ b/src/libraries/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeFileHandle.Windows.cs @@ -203,9 +203,10 @@ private static unsafe void Preallocate(string fullPath, long preallocationSize, { int errorCode = Marshal.GetLastPInvokeError(); - // Only throw for errors that indicate there is not enough space. - // SetFileInformationByHandle fails with ERROR_DISK_FULL in certain cases when the size is disallowed by filesystem, - // such as >4GB on FAT32 volume. We cannot distinguish them currently. + // Only throw for errors that indicate there is not enough space or the file is too large. + // SetFileInformationByHandle fails with ERROR_DISK_FULL when the size is disallowed by filesystem, + // such as >4GB on a FAT32 volume, and with ERROR_INVALID_PARAMETER on NTFS when the requested + // allocation size exceeds the maximum file size supported by the filesystem or volume configuration. if (errorCode is Interop.Errors.ERROR_DISK_FULL or Interop.Errors.ERROR_FILE_TOO_LARGE or Interop.Errors.ERROR_INVALID_PARAMETER) diff --git a/src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/FileStream/ctor_options.cs b/src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/FileStream/ctor_options.cs index 29b2ba714060a8..1af6421d86c0ab 100644 --- a/src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/FileStream/ctor_options.cs +++ b/src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/FileStream/ctor_options.cs @@ -152,7 +152,6 @@ public void PreallocationSize(FileAccess access, FileMode mode) } } - [ActiveIssue("https://github.com/dotnet/runtime/issues/92624", TestPlatforms.Windows)] // macOS fcntl doc does not mention ENOSPC error: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/fcntl.2.html // But depending on the OS version, it might actually return it. // Since we don't want to have unstable tests, it's better to not run it on macOS at all.