diff --git a/src/Renci.SshNet/ISftpClient.cs b/src/Renci.SshNet/ISftpClient.cs
index af6d31b94..90edc68e2 100644
--- a/src/Renci.SshNet/ISftpClient.cs
+++ b/src/Renci.SshNet/ISftpClient.cs
@@ -389,7 +389,7 @@ public interface ISftpClient : IBaseClient
///
/// The path and name of the file to create.
///
- /// A that provides read/write access to the file specified in path.
+ /// A that provides read/write access to the file specified in path.
///
/// is .
/// Client is not connected.
@@ -398,7 +398,7 @@ public interface ISftpClient : IBaseClient
///
/// If the target file already exists, it is first truncated to zero bytes.
///
- SftpFileStream Create(string path);
+ Stream Create(string path);
///
/// Creates or overwrites the specified file.
@@ -406,7 +406,7 @@ public interface ISftpClient : IBaseClient
/// The path and name of the file to create.
/// The maximum number of bytes buffered for reads and writes to the file.
///
- /// A that provides read/write access to the file specified in path.
+ /// A that provides read/write access to the file specified in path.
///
/// is .
/// Client is not connected.
@@ -415,7 +415,7 @@ public interface ISftpClient : IBaseClient
///
/// If the target file already exists, it is first truncated to zero bytes.
///
- SftpFileStream Create(string path, int bufferSize);
+ Stream Create(string path, int bufferSize);
///
/// Creates remote directory specified by path.
@@ -817,59 +817,59 @@ public interface ISftpClient : IBaseClient
IAsyncEnumerable ListDirectoryAsync(string path, CancellationToken cancellationToken);
///
- /// Opens a on the specified path with read/write access.
+ /// Opens a on the specified path with read/write access.
///
/// The file to open.
/// A value that specifies whether a file is created if one does not exist, and determines whether the contents of existing files are retained or overwritten.
///
- /// An unshared that provides access to the specified file, with the specified mode and read/write access.
+ /// An unshared that provides access to the specified file, with the specified mode and read/write access.
///
/// is .
/// Client is not connected.
/// The method was called after the client was disposed.
- SftpFileStream Open(string path, FileMode mode);
+ Stream Open(string path, FileMode mode);
///
- /// Opens a on the specified path, with the specified mode and access.
+ /// Opens a on the specified path, with the specified mode and access.
///
/// The file to open.
/// A value that specifies whether a file is created if one does not exist, and determines whether the contents of existing files are retained or overwritten.
/// A value that specifies the operations that can be performed on the file.
///
- /// An unshared that provides access to the specified file, with the specified mode and access.
+ /// An unshared that provides access to the specified file, with the specified mode and access.
///
/// is .
/// Client is not connected.
/// The method was called after the client was disposed.
- SftpFileStream Open(string path, FileMode mode, FileAccess access);
+ Stream Open(string path, FileMode mode, FileAccess access);
///
- /// Asynchronously opens a on the specified path, with the specified mode and access.
+ /// Asynchronously opens a on the specified path, with the specified mode and access.
///
/// The file to open.
/// A value that specifies whether a file is created if one does not exist, and determines whether the contents of existing files are retained or overwritten.
/// A value that specifies the operations that can be performed on the file.
/// The to observe.
///
- /// A that represents the asynchronous open operation.
- /// The task result contains the that provides access to the specified file, with the specified mode and access.
+ /// A that represents the asynchronous open operation.
+ /// The task result contains the that provides access to the specified file, with the specified mode and access.
///
/// is .
/// Client is not connected.
/// The method was called after the client was disposed.
- Task OpenAsync(string path, FileMode mode, FileAccess access, CancellationToken cancellationToken);
+ Task OpenAsync(string path, FileMode mode, FileAccess access, CancellationToken cancellationToken);
///
/// Opens an existing file for reading.
///
/// The file to be opened for reading.
///
- /// A read-only on the specified path.
+ /// A read-only on the specified path.
///
/// is .
/// Client is not connected.
/// The method was called after the client was disposed.
- SftpFileStream OpenRead(string path);
+ Stream OpenRead(string path);
///
/// Opens an existing UTF-8 encoded text file for reading.
@@ -888,7 +888,7 @@ public interface ISftpClient : IBaseClient
///
/// The file to be opened for writing.
///
- /// An unshared object on the specified path with access.
+ /// An unshared object on the specified path with access.
///
/// is .
/// Client is not connected.
@@ -896,7 +896,7 @@ public interface ISftpClient : IBaseClient
///
/// If the file does not exist, it is created.
///
- SftpFileStream OpenWrite(string path);
+ Stream OpenWrite(string path);
///
/// Opens a binary file, reads the contents of the file into a byte array, and closes the file.
diff --git a/src/Renci.SshNet/SftpClient.cs b/src/Renci.SshNet/SftpClient.cs
index 77014e9a3..7140c846b 100644
--- a/src/Renci.SshNet/SftpClient.cs
+++ b/src/Renci.SshNet/SftpClient.cs
@@ -1457,7 +1457,7 @@ public StreamWriter AppendText(string path, Encoding encoding)
///
/// The path and name of the file to create.
///
- /// A that provides read/write access to the file specified in path.
+ /// A that provides read/write access to the file specified in path.
///
/// is .
/// Client is not connected.
@@ -1466,7 +1466,7 @@ public StreamWriter AppendText(string path, Encoding encoding)
///
/// If the target file already exists, it is first truncated to zero bytes.
///
- public SftpFileStream Create(string path)
+ public Stream Create(string path)
{
return Create(path, (int)_bufferSize);
}
@@ -1477,7 +1477,7 @@ public SftpFileStream Create(string path)
/// The path and name of the file to create.
/// The maximum number of bytes buffered for reads and writes to the file.
///
- /// A that provides read/write access to the file specified in path.
+ /// A that provides read/write access to the file specified in path.
///
/// is .
/// Client is not connected.
@@ -1486,7 +1486,7 @@ public SftpFileStream Create(string path)
///
/// If the target file already exists, it is first truncated to zero bytes.
///
- public SftpFileStream Create(string path, int bufferSize)
+ public Stream Create(string path, int bufferSize)
{
CheckDisposed();
@@ -1597,34 +1597,34 @@ public DateTime GetLastWriteTimeUtc(string path)
}
///
- /// Opens a on the specified path with read/write access.
+ /// Opens a on the specified path with read/write access.
///
/// The file to open.
/// A value that specifies whether a file is created if one does not exist, and determines whether the contents of existing files are retained or overwritten.
///
- /// An unshared that provides access to the specified file, with the specified mode and read/write access.
+ /// An unshared that provides access to the specified file, with the specified mode and read/write access.
///
/// is .
/// Client is not connected.
/// The method was called after the client was disposed.
- public SftpFileStream Open(string path, FileMode mode)
+ public Stream Open(string path, FileMode mode)
{
return Open(path, mode, FileAccess.ReadWrite);
}
///
- /// Opens a on the specified path, with the specified mode and access.
+ /// Opens a on the specified path, with the specified mode and access.
///
/// The file to open.
/// A value that specifies whether a file is created if one does not exist, and determines whether the contents of existing files are retained or overwritten.
/// A value that specifies the operations that can be performed on the file.
///
- /// An unshared that provides access to the specified file, with the specified mode and access.
+ /// An unshared that provides access to the specified file, with the specified mode and access.
///
/// is .
/// Client is not connected.
/// The method was called after the client was disposed.
- public SftpFileStream Open(string path, FileMode mode, FileAccess access)
+ public Stream Open(string path, FileMode mode, FileAccess access)
{
CheckDisposed();
@@ -1632,24 +1632,24 @@ public SftpFileStream Open(string path, FileMode mode, FileAccess access)
}
///
- /// Asynchronously opens a on the specified path, with the specified mode and access.
+ /// Asynchronously opens a on the specified path, with the specified mode and access.
///
/// The file to open.
/// A value that specifies whether a file is created if one does not exist, and determines whether the contents of existing files are retained or overwritten.
/// A value that specifies the operations that can be performed on the file.
/// The to observe.
///
- /// A that represents the asynchronous open operation.
- /// The task result contains the that provides access to the specified file, with the specified mode and access.
+ /// A that represents the asynchronous open operation.
+ /// The task result contains the that provides access to the specified file, with the specified mode and access.
///
/// is .
/// Client is not connected.
/// The method was called after the client was disposed.
- public Task OpenAsync(string path, FileMode mode, FileAccess access, CancellationToken cancellationToken)
+ public async Task OpenAsync(string path, FileMode mode, FileAccess access, CancellationToken cancellationToken)
{
CheckDisposed();
- return SftpFileStream.OpenAsync(_sftpSession, path, mode, access, (int)_bufferSize, cancellationToken);
+ return await SftpFileStream.OpenAsync(_sftpSession, path, mode, access, (int)_bufferSize, cancellationToken).ConfigureAwait(false);
}
///
@@ -1657,12 +1657,12 @@ public Task OpenAsync(string path, FileMode mode, FileAccess acc
///
/// The file to be opened for reading.
///
- /// A read-only on the specified path.
+ /// A read-only on the specified path.
///
/// is .
/// Client is not connected.
/// The method was called after the client was disposed.
- public SftpFileStream OpenRead(string path)
+ public Stream OpenRead(string path)
{
return Open(path, FileMode.Open, FileAccess.Read);
}
@@ -1687,7 +1687,7 @@ public StreamReader OpenText(string path)
///
/// The file to be opened for writing.
///
- /// An unshared object on the specified path with access.
+ /// An unshared object on the specified path with access.
///
/// is .
/// Client is not connected.
@@ -1695,7 +1695,7 @@ public StreamReader OpenText(string path)
///
/// If the file does not exist, it is created.
///
- public SftpFileStream OpenWrite(string path)
+ public Stream OpenWrite(string path)
{
return Open(path, FileMode.OpenOrCreate, FileAccess.Write);
}
diff --git a/test/Renci.SshNet.IntegrationTests/SftpTests.cs b/test/Renci.SshNet.IntegrationTests/SftpTests.cs
index bc404d439..d3a490cd3 100644
--- a/test/Renci.SshNet.IntegrationTests/SftpTests.cs
+++ b/test/Renci.SshNet.IntegrationTests/SftpTests.cs
@@ -256,7 +256,7 @@ public void Sftp_Create_DirectoryDoesNotExist()
client.DeleteFile(remoteFile);
}
- SftpFileStream fs = null;
+ Stream fs = null;
try
{
@@ -4000,8 +4000,8 @@ public void Sftp_SftpFileStream_ReadAndWriteAsyncMemory()
#endif
private void TestReadAndWrite(
- Func read,
- Action write)
+ Func read,
+ Action write)
{
using (var client = new SftpClient(_connectionInfoFactory.Create()))
{
@@ -4107,14 +4107,14 @@ private void TestReadAndWrite(
}
}
- int ReadByte(SftpFileStream s)
+ int ReadByte(Stream s)
{
var buffer = new byte[1];
var bytesRead = read(s, buffer, 0, 1);
return bytesRead == 0 ? -1 : buffer[0];
}
- void WriteByte(SftpFileStream s, byte b)
+ void WriteByte(Stream s, byte b)
{
write(s, [b], 0, 1);
}
diff --git a/test/Renci.SshNet.Tests/Classes/SftpClientTest_AsyncExceptions.cs b/test/Renci.SshNet.Tests/Classes/SftpClientTest_AsyncExceptions.cs
index c3e5affb5..7fa0e75af 100644
--- a/test/Renci.SshNet.Tests/Classes/SftpClientTest_AsyncExceptions.cs
+++ b/test/Renci.SshNet.Tests/Classes/SftpClientTest_AsyncExceptions.cs
@@ -65,7 +65,7 @@ public void Init()
[TestMethod]
public async Task Async_ObservesSessionDisconnected()
{
- Task openTask = _client.OpenAsync("path", FileMode.Create, FileAccess.Write, CancellationToken.None);
+ var openTask = _client.OpenAsync("path", FileMode.Create, FileAccess.Write, CancellationToken.None);
Assert.IsFalse(openTask.IsCompleted);
@@ -78,7 +78,7 @@ public async Task Async_ObservesSessionDisconnected()
[TestMethod]
public async Task Async_ObservesChannelClosed()
{
- Task openTask = _client.OpenAsync("path", FileMode.Create, FileAccess.Write, CancellationToken.None);
+ var openTask = _client.OpenAsync("path", FileMode.Create, FileAccess.Write, CancellationToken.None);
Assert.IsFalse(openTask.IsCompleted);
@@ -93,7 +93,7 @@ public async Task Async_ObservesCancellationToken()
{
using CancellationTokenSource cts = new();
- Task openTask = _client.OpenAsync("path", FileMode.Create, FileAccess.Write, cts.Token);
+ var openTask = _client.OpenAsync("path", FileMode.Create, FileAccess.Write, cts.Token);
Assert.IsFalse(openTask.IsCompleted);
@@ -108,7 +108,7 @@ public async Task Async_ObservesOperationTimeout()
{
_client.OperationTimeout = TimeSpan.FromMilliseconds(250);
- Task openTask = _client.OpenAsync("path", FileMode.Create, FileAccess.Write, CancellationToken.None);
+ var openTask = _client.OpenAsync("path", FileMode.Create, FileAccess.Write, CancellationToken.None);
var ex = await Assert.ThrowsExactlyAsync(() => openTask);
}
@@ -116,7 +116,7 @@ public async Task Async_ObservesOperationTimeout()
[TestMethod]
public async Task Async_ObservesErrorOccurred()
{
- Task openTask = _client.OpenAsync("path", FileMode.Create, FileAccess.Write, CancellationToken.None);
+ var openTask = _client.OpenAsync("path", FileMode.Create, FileAccess.Write, CancellationToken.None);
Assert.IsFalse(openTask.IsCompleted);