Skip to content

Commit

Permalink
Added properties for FileShare and BufferSize used by FileStream cons…
Browse files Browse the repository at this point in the history
…tructor
  • Loading branch information
Arlodotexe committed Nov 20, 2024
1 parent 2e887d0 commit 19e4468
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/System/IO/SystemFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,19 @@ internal SystemFile(FileInfo info, bool noValidation)
/// </summary>
public string Path { get; }

/// <summary>
/// Contains constants for controlling the kind of access other operations can have to the same file.
/// </summary>
/// <remarks>
/// This enumeration supports a bitwise combination of its member values. A typical use of this enumeration is to define whether two processes can simultaneously read from the same file. For example, if a file is opened and Read is specified, other users can open the file for reading but not for writing.
/// </remarks>
public FileShare FileShare { get; set; } = FileShare.None;

/// <summary>
/// A positive Int32 value greater than 0 indicating the buffer size. The default buffer size is 4096.
/// </summary>
public int BufferSize { get; set; } = 4096;

/// <summary>
/// Gets the underlying <see cref="FileInfo"/> for this folder.
/// </summary>
Expand All @@ -103,7 +116,7 @@ internal SystemFile(FileInfo info, bool noValidation)
/// <inheritdoc />
public Task<Stream> OpenStreamAsync(FileAccess accessMode = FileAccess.Read, CancellationToken cancellationToken = default)
{
var stream = new FileStream(Path, FileMode.Open, accessMode, FileShare.None, 4096, FileOptions.Asynchronous);
var stream = new FileStream(Path, FileMode.Open, accessMode, FileShare, BufferSize, FileOptions.Asynchronous);
cancellationToken.ThrowIfCancellationRequested();

return Task.FromResult<Stream>(stream);
Expand Down

0 comments on commit 19e4468

Please sign in to comment.