Skip to content

Commit 0b9f734

Browse files
Copilotstephentoub
andauthored
Improve error message when seeking to negative position in FileStream (#120626)
Fixes #112112 Co-authored-by: stephentoub <[email protected]>
1 parent f9dc66b commit 0b9f734

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/libraries/System.Private.CoreLib/src/System/IO/Strategies/OSFileStreamStrategy.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@ public sealed override long Seek(long offset, SeekOrigin origin)
158158
}
159159
else
160160
{
161-
// keep throwing the same exception we did when seek was causing actual offset change
162-
FileStreamHelpers.ThrowInvalidArgument(_fileHandle);
161+
// keep throwing the same exception type we did when seek was causing actual offset change
162+
throw new IOException(SR.IO_SeekBeforeBegin);
163163
}
164164

165165
// Prevent users from overwriting data in a file that was opened in append mode.

0 commit comments

Comments
 (0)