From a54911e3e8230ab7fc1cb118e87b6c11402bda2f Mon Sep 17 00:00:00 2001 From: Robin Rodricks Date: Sun, 6 Feb 2022 11:34:46 +0530 Subject: [PATCH] delete old open series api --- FluentFTP.CSharpExamples/OpenAppend.cs | 56 ----- FluentFTP.CSharpExamples/OpenRead.cs | 56 ----- FluentFTP.CSharpExamples/OpenWrite.cs | 44 ---- FluentFTP.Tests/Tests.cs | 2 +- FluentFTP.VBExamples/OpenAppend.vb | 55 ----- FluentFTP.VBExamples/OpenRead.vb | 55 ----- FluentFTP.VBExamples/OpenWrite.vb | 43 ---- FluentFTP.VBExamples/VBExamples.vbproj | 3 - FluentFTP/Client/FtpClient_Stream.cs | 277 +++++-------------------- FluentFTP/Client/IFtpClient.cs | 30 +-- 10 files changed, 61 insertions(+), 560 deletions(-) delete mode 100644 FluentFTP.CSharpExamples/OpenAppend.cs delete mode 100644 FluentFTP.CSharpExamples/OpenRead.cs delete mode 100644 FluentFTP.CSharpExamples/OpenWrite.cs delete mode 100644 FluentFTP.VBExamples/OpenAppend.vb delete mode 100644 FluentFTP.VBExamples/OpenRead.vb delete mode 100644 FluentFTP.VBExamples/OpenWrite.vb diff --git a/FluentFTP.CSharpExamples/OpenAppend.cs b/FluentFTP.CSharpExamples/OpenAppend.cs deleted file mode 100644 index b0cb8a982..000000000 --- a/FluentFTP.CSharpExamples/OpenAppend.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System; -using System.Net; -using System.Threading; -using System.Threading.Tasks; -using FluentFTP; - -namespace Examples { - internal static class OpenAppendExample { - - public static void OpenAppend() { - using (var conn = new FtpClient("127.0.0.1", "ftptest", "ftptest")) { - conn.Connect(); - - // open an append-only stream to the file - using (var ostream = conn.OpenAppend("/full/or/relative/path/to/file")) { - try { - // be sure to seek your output stream to the appropriate location, i.e., istream.Position - // istream.Position is incremented accordingly to the writes you perform - // istream.Position == file size if the server supports getting the file size - // also note that file size for the same file can vary between ASCII and Binary - // modes and some servers won't even give a file size for ASCII files! It is - // recommended that you stick with Binary and worry about character encodings - // on your end of the connection. - } - finally { - ostream.Close(); - } - } - } - } - - public static async Task OpenAppendAsync() { - var token = new CancellationToken(); - using (var conn = new FtpClient("127.0.0.1", "ftptest", "ftptest")) { - await conn.ConnectAsync(token); - - // open an append-only stream to the file - using (var ostream = await conn.OpenAppendAsync("/full/or/relative/path/to/file", token)) { - try { - // be sure to seek your output stream to the appropriate location, i.e., istream.Position - // istream.Position is incremented accordingly to the writes you perform - // istream.Position == file size if the server supports getting the file size - // also note that file size for the same file can vary between ASCII and Binary - // modes and some servers won't even give a file size for ASCII files! It is - // recommended that you stick with Binary and worry about character encodings - // on your end of the connection. - } - finally { - ostream.Close(); - } - } - } - } - - } -} \ No newline at end of file diff --git a/FluentFTP.CSharpExamples/OpenRead.cs b/FluentFTP.CSharpExamples/OpenRead.cs deleted file mode 100644 index 20de2855b..000000000 --- a/FluentFTP.CSharpExamples/OpenRead.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System; -using System.Net; -using System.Threading; -using System.Threading.Tasks; -using FluentFTP; - -namespace Examples { - internal static class OpenReadExample { - - public static void OpenRead() { - using (var conn = new FtpClient("127.0.0.1", "ftptest", "ftptest")) { - conn.Connect(); - - // open an read-only stream to the file - using (var istream = conn.OpenRead("/full/or/relative/path/to/file")) { - try { - // istream.Position is incremented accordingly to the reads you perform - // istream.Length == file size if the server supports getting the file size - // also note that file size for the same file can vary between ASCII and Binary - // modes and some servers won't even give a file size for ASCII files! It is - // recommended that you stick with Binary and worry about character encodings - // on your end of the connection. - } - finally { - Console.WriteLine(); - istream.Close(); - } - } - } - } - - public static async Task OpenReadAsync() { - var token = new CancellationToken(); - using (var conn = new FtpClient("127.0.0.1", "ftptest", "ftptest")) { - await conn.ConnectAsync(token); - - // open an read-only stream to the file - using (var istream = await conn.OpenReadAsync("/full/or/relative/path/to/file", token)) { - try { - // istream.Position is incremented accordingly to the reads you perform - // istream.Length == file size if the server supports getting the file size - // also note that file size for the same file can vary between ASCII and Binary - // modes and some servers won't even give a file size for ASCII files! It is - // recommended that you stick with Binary and worry about character encodings - // on your end of the connection. - } - finally { - Console.WriteLine(); - istream.Close(); - } - } - } - } - - } -} \ No newline at end of file diff --git a/FluentFTP.CSharpExamples/OpenWrite.cs b/FluentFTP.CSharpExamples/OpenWrite.cs deleted file mode 100644 index 9db05e005..000000000 --- a/FluentFTP.CSharpExamples/OpenWrite.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System; -using System.Net; -using System.Threading; -using System.Threading.Tasks; -using FluentFTP; - -namespace Examples { - internal static class OpenWriteExample { - - public static void OpenWrite() { - using (var conn = new FtpClient("127.0.0.1", "ftptest", "ftptest")) { - conn.Connect(); - - // open an write-only stream to the file - using (var ostream = conn.OpenWrite("/full/or/relative/path/to/file")) { - try { - // ostream.Position is incremented accordingly to the writes you perform - } - finally { - ostream.Close(); - } - } - } - } - - public static async Task OpenWriteAsync() { - var token = new CancellationToken(); - using (var conn = new FtpClient("127.0.0.1", "ftptest", "ftptest")) { - await conn.ConnectAsync(token); - - // open an write-only stream to the file - using (var ostream = await conn.OpenWriteAsync("/full/or/relative/path/to/file", token)) { - try { - // ostream.Position is incremented accordingly to the writes you perform - } - finally { - ostream.Close(); - } - } - } - } - - } -} \ No newline at end of file diff --git a/FluentFTP.Tests/Tests.cs b/FluentFTP.Tests/Tests.cs index 5f14dac15..f7b005087 100644 --- a/FluentFTP.Tests/Tests.cs +++ b/FluentFTP.Tests/Tests.cs @@ -789,7 +789,7 @@ public void TestReset() { using (var cl = NewFtpClient()) { cl.Connect(); - using (var istream = cl.OpenRead("LICENSE.TXT", 10)) { + using (var istream = cl.OpenRead("LICENSE.TXT", FtpDataType.Binary, 10)) { } } } diff --git a/FluentFTP.VBExamples/OpenAppend.vb b/FluentFTP.VBExamples/OpenAppend.vb deleted file mode 100644 index 15b57c019..000000000 --- a/FluentFTP.VBExamples/OpenAppend.vb +++ /dev/null @@ -1,55 +0,0 @@ -Imports System -Imports System.Net -Imports System.Threading -Imports System.Threading.Tasks -Imports FluentFTP - -Namespace Examples - Friend Module OpenAppendExample - Sub OpenAppend() - Using conn = New FtpClient("127.0.0.1", "ftptest", "ftptest") - conn.Connect() - - ' open an append-only stream to the file - Using ostream = conn.OpenAppend("/full/or/relative/path/to/file") - - Try - ' be sure to seek your output stream to the appropriate location, i.e., istream.Position - ' istream.Position Is incremented accordingly to the writes you perform - ' istream.Position == file size if the server supports getting the file size - ' also note that file size for the same file can vary between ASCII And Binary - ' modes And some servers won't even give a file size for ASCII files! It is - ' recommended that you stick with Binary And worry about character encodings - ' on your end of the connection. - Finally - ostream.Close() - End Try - End Using - End Using - End Sub - - Async Function OpenAppendAsync() As Task - Dim token = New CancellationToken() - - Using conn = New FtpClient("127.0.0.1", "ftptest", "ftptest") - Await conn.ConnectAsync(token) - - ' open an append-only stream to the file - Using ostream = Await conn.OpenAppendAsync("/full/or/relative/path/to/file", token) - - Try - ' be sure to seek your output stream to the appropriate location, i.e., istream.Position - ' istream.Position Is incremented accordingly to the writes you perform - ' istream.Position == file size if the server supports getting the file size - ' also note that file size for the same file can vary between ASCII And Binary - ' modes And some servers won't even give a file size for ASCII files! It is - ' recommended that you stick with Binary And worry about character encodings - ' on your end of the connection. - Finally - ostream.Close() - End Try - End Using - End Using - End Function - End Module -End Namespace diff --git a/FluentFTP.VBExamples/OpenRead.vb b/FluentFTP.VBExamples/OpenRead.vb deleted file mode 100644 index f413fefb2..000000000 --- a/FluentFTP.VBExamples/OpenRead.vb +++ /dev/null @@ -1,55 +0,0 @@ -Imports System -Imports System.Net -Imports System.Threading -Imports System.Threading.Tasks -Imports FluentFTP - -Namespace Examples - Friend Module OpenReadExample - Sub OpenRead() - Using conn = New FtpClient("127.0.0.1", "ftptest", "ftptest") - conn.Connect() - - ' open an read-only stream to the file - Using istream = conn.OpenRead("/full/or/relative/path/to/file") - - Try - ' istream.Position Is incremented accordingly to the reads you perform - ' istream.Length == file size if the server supports getting the file size - ' also note that file size for the same file can vary between ASCII And Binary - ' modes And some servers won't even give a file size for ASCII files! It is - ' recommended that you stick with Binary And worry about character encodings - ' on your end of the connection. - Finally - Console.WriteLine() - istream.Close() - End Try - End Using - End Using - End Sub - - Async Function OpenReadAsync() As Task - Dim token = New CancellationToken() - - Using conn = New FtpClient("127.0.0.1", "ftptest", "ftptest") - Await conn.ConnectAsync(token) - - ' open an read-only stream to the file - Using istream = Await conn.OpenReadAsync("/full/or/relative/path/to/file", token) - - Try - ' istream.Position Is incremented accordingly to the reads you perform - ' istream.Length == file size if the server supports getting the file size - ' also note that file size for the same file can vary between ASCII And Binary - ' modes And some servers won't even give a file size for ASCII files! It is - ' recommended that you stick with Binary And worry about character encodings - ' on your end of the connection. - Finally - Console.WriteLine() - istream.Close() - End Try - End Using - End Using - End Function - End Module -End Namespace diff --git a/FluentFTP.VBExamples/OpenWrite.vb b/FluentFTP.VBExamples/OpenWrite.vb deleted file mode 100644 index 5b895bf9f..000000000 --- a/FluentFTP.VBExamples/OpenWrite.vb +++ /dev/null @@ -1,43 +0,0 @@ -Imports System -Imports System.Net -Imports System.Threading -Imports System.Threading.Tasks -Imports FluentFTP - -Namespace Examples - Friend Module OpenWriteExample - Sub OpenWrite() - Using conn = New FtpClient("127.0.0.1", "ftptest", "ftptest") - conn.Connect() - - ' open an write-only stream to the file - Using ostream = conn.OpenWrite("/full/or/relative/path/to/file") - - Try - ' ostream.Position Is incremented accordingly to the writes you perform - Finally - ostream.Close() - End Try - End Using - End Using - End Sub - - Async Function OpenWriteAsync() As Task - Dim token = New CancellationToken() - - Using conn = New FtpClient("127.0.0.1", "ftptest", "ftptest") - Await conn.ConnectAsync(token) - - ' open an write-only stream to the file - Using ostream = Await conn.OpenWriteAsync("/full/or/relative/path/to/file", token) - - Try - ' ostream.Position Is incremented accordingly to the writes you perform - Finally - ostream.Close() - End Try - End Using - End Using - End Function - End Module -End Namespace diff --git a/FluentFTP.VBExamples/VBExamples.vbproj b/FluentFTP.VBExamples/VBExamples.vbproj index a2a18ba05..37c790e82 100644 --- a/FluentFTP.VBExamples/VBExamples.vbproj +++ b/FluentFTP.VBExamples/VBExamples.vbproj @@ -87,9 +87,6 @@ - - - diff --git a/FluentFTP/Client/FtpClient_Stream.cs b/FluentFTP/Client/FtpClient_Stream.cs index 3fc27227a..02e727346 100644 --- a/FluentFTP/Client/FtpClient_Stream.cs +++ b/FluentFTP/Client/FtpClient_Stream.cs @@ -1134,77 +1134,16 @@ private void StartListeningOnPort(FtpDataStream stream) { #region Open Read - /// - /// Opens the specified file for reading - /// - /// The full or relative path of the file - /// A stream for reading the file on the server - public Stream OpenRead(string path) { - return OpenRead(path, FtpDataType.Binary, 0, 0); - } - - /// - /// Opens the specified file for reading - /// - /// The full or relative path of the file - /// ASCII/Binary - /// A stream for reading the file on the server - public Stream OpenRead(string path, FtpDataType type) { - return OpenRead(path, type, 0, 0); - } - - /// - /// Opens the specified file for reading - /// - /// The full or relative path of the file - /// ASCII/Binary - /// Only set this to false if you are SURE that the file does not exist. If true, it reads the file size and saves it into the stream length. - /// A stream for reading the file on the server - public Stream OpenRead(string path, FtpDataType type, bool checkIfFileExists) { - return OpenRead(path, type, 0, checkIfFileExists ? 0 : -1); - } - /// /// Opens the specified file for reading /// /// The full or relative path of the file /// ASCII/Binary /// Resume location - /// A stream for reading the file on the server - public virtual Stream OpenRead(string path, FtpDataType type, long restart) { - return OpenRead(path, type, restart, 0); - } - - /// - /// Opens the specified file for reading - /// - /// The full or relative path of the file - /// Resume location - /// A stream for reading the file on the server - public Stream OpenRead(string path, long restart) { - return OpenRead(path, FtpDataType.Binary, restart, 0); - } - - /// - /// Opens the specified file for reading - /// - /// The full or relative path of the file - /// Resume location /// Only set this to false if you are SURE that the file does not exist. If true, it reads the file size and saves it into the stream length. /// A stream for reading the file on the server - public Stream OpenRead(string path, long restart, bool checkIfFileExists) { - return OpenRead(path, FtpDataType.Binary, restart, checkIfFileExists ? 0 : -1); - } - - /// - /// Opens the specified file for reading - /// - /// The full or relative path of the file - /// ASCII/Binary - /// Resume location - /// Only set this to false if you are SURE that the file does not exist. If true, it reads the file size and saves it into the stream length. - /// A stream for reading the file on the server - public virtual Stream OpenRead(string path, FtpDataType type, long restart, bool checkIfFileExists) { + [Obsolete("OpenRead() is obsolete, please use Download() or DownloadFile() instead", false)] + public virtual Stream OpenRead(string path, FtpDataType type = FtpDataType.Binary, long restart = 0, bool checkIfFileExists = true) { return OpenRead(path, type, restart, checkIfFileExists ? 0 : -1); } @@ -1221,6 +1160,7 @@ public virtual Stream OpenRead(string path, FtpDataType type, long restart, bool ///
>0 => File length is KNOWN. No need to determine it
/// /// A stream for reading the file on the server + [Obsolete("OpenRead() is obsolete, please use Download() or DownloadFile() instead", false)] public virtual Stream OpenRead(string path, FtpDataType type, long restart, long fileLen) { // verify args if (path.IsBlank()) { @@ -1270,6 +1210,22 @@ public virtual Stream OpenRead(string path, FtpDataType type, long restart, long } #if ASYNC + + /// + /// Opens the specified file for reading asynchronously + /// + /// The full or relative path of the file + /// ASCII/Binary + /// Resume location + /// Only set this to false if you are SURE that the file does not exist. If true, it reads the file size and saves it into the stream length. + /// The token that can be used to cancel the entire process + /// A stream for reading the file on the server + [Obsolete("OpenReadAsync() is obsolete, please use DownloadAsync() or DownloadFileAsync() instead", false)] + public virtual Task OpenReadAsync(string path, FtpDataType type = FtpDataType.Binary, long restart = 0, + bool checkIfFileExists = true, CancellationToken token = default(CancellationToken)) { + return OpenReadAsync(path, type, restart, checkIfFileExists ? 0 : -1, token); + } + /// /// Opens the specified file for reading asynchronously /// @@ -1284,6 +1240,7 @@ public virtual Stream OpenRead(string path, FtpDataType type, long restart, long /// /// The token that can be used to cancel the entire process /// A stream for reading the file on the server + [Obsolete("OpenReadAsync() is obsolete, please use DownloadAsync() or DownloadFileAsync() instead", false)] public virtual async Task OpenReadAsync(string path, FtpDataType type, long restart, long fileLen, CancellationToken token = default(CancellationToken)) { // verify args if (path.IsBlank()) { @@ -1326,87 +1283,12 @@ public virtual Stream OpenRead(string path, FtpDataType type, long restart, long return stream; } - /// - /// Opens the specified file for reading asynchronously - /// - /// The full or relative path of the file - /// ASCII/Binary - /// Resume location - /// Only set this to false if you are SURE that the file does not exist. If true, it reads the file size and saves it into the stream length. - /// The token that can be used to cancel the entire process - /// A stream for reading the file on the server - public virtual Task OpenReadAsync(string path, FtpDataType type, long restart, bool checkIfFileExists, CancellationToken token = default(CancellationToken)) { - return OpenReadAsync(path, type, restart, checkIfFileExists ? 0 : -1, token); - } - - /// - /// Opens the specified file for reading asynchronously - /// - /// The full or relative path of the file - /// ASCII/Binary - /// Resume location - /// The token that can be used to cancel the entire process - /// A readable stream of the remote file - public Task OpenReadAsync(string path, FtpDataType type, long restart, CancellationToken token = default(CancellationToken)) { - return OpenReadAsync(path, type, restart, 0, token); - } - - /// - /// Opens the specified file for reading asynchronously - /// - /// The full or relative path of the file - /// ASCII/Binary - /// The token that can be used to cancel the entire process - /// A readable stream of the remote file - public Task OpenReadAsync(string path, FtpDataType type, CancellationToken token = default(CancellationToken)) { - return OpenReadAsync(path, type, 0, 0, token); - } - - /// - /// Opens the specified file for reading asynchronously - /// - /// The full or relative path of the file - /// Resume location - /// The token that can be used to cancel the entire process - /// A readable stream of the remote file - public Task OpenReadAsync(string path, long restart, CancellationToken token = default(CancellationToken)) { - return OpenReadAsync(path, FtpDataType.Binary, restart, 0, token); - } - - /// - /// Opens the specified file for reading asynchronously - /// - /// The full or relative path of the file - /// The token that can be used to cancel the entire process - /// A readable stream of the remote file - public Task OpenReadAsync(string path, CancellationToken token = default(CancellationToken)) { - return OpenReadAsync(path, FtpDataType.Binary, 0, 0, token); - } #endif #endregion #region Open Write - /// - /// Opens the specified file for writing. Please call GetReply() after you have successfully transfered the file to read the "OK" command sent by the server and prevent stale data on the socket. - /// - /// Full or relative path of the file - /// A stream for writing to the file on the server - public Stream OpenWrite(string path) { - return OpenWrite(path, FtpDataType.Binary, 0); - } - - /// - /// Opens the specified file for writing. Please call GetReply() after you have successfully transfered the file to read the "OK" command sent by the server and prevent stale data on the socket. - /// - /// Full or relative path of the file - /// ASCII/Binary - /// A stream for writing to the file on the server - public virtual Stream OpenWrite(string path, FtpDataType type) { - return OpenWrite(path, type, 0); - } - /// /// Opens the specified file for writing. Please call GetReply() after you have successfully transfered the file to read the "OK" command sent by the server and prevent stale data on the socket. /// @@ -1414,7 +1296,8 @@ public virtual Stream OpenWrite(string path, FtpDataType type) { /// ASCII/Binary /// Only set this to false if you are SURE that the file does not exist. If true, it reads the file size and saves it into the stream length. /// A stream for writing to the file on the server - public virtual Stream OpenWrite(string path, FtpDataType type, bool checkIfFileExists) { + [Obsolete("OpenWrite() is obsolete, please use Upload() or UploadFile() instead", false)] + public virtual Stream OpenWrite(string path, FtpDataType type = FtpDataType.Binary, bool checkIfFileExists = true) { return OpenWrite(path, type, checkIfFileExists ? 0 : -1); } @@ -1430,6 +1313,7 @@ public virtual Stream OpenWrite(string path, FtpDataType type, bool checkIfFileE ///
>0 => File length is KNOWN. No need to determine it
/// /// A stream for writing to the file on the server + [Obsolete("OpenWrite() is obsolete, please use Upload() or UploadFile() instead", false)] public virtual Stream OpenWrite(string path, FtpDataType type, long fileLen) { // verify args if (path.IsBlank()) { @@ -1473,6 +1357,19 @@ public virtual Stream OpenWrite(string path, FtpDataType type, long fileLen) { return stream; } #if ASYNC + /// + /// Opens the specified file for writing. Please call GetReply() after you have successfully transfered the file to read the "OK" command sent by the server and prevent stale data on the socket. + /// + /// Full or relative path of the file + /// ASCII/Binary + /// Only set this to false if you are SURE that the file does not exist. If true, it reads the file size and saves it into the stream length. + /// The token that can be used to cancel the entire process + /// A stream for writing to the file on the server + [Obsolete("OpenWriteAsync() is obsolete, please use UploadAsync() or UploadFileAsync() instead", false)] + public virtual Task OpenWriteAsync(string path, FtpDataType type = FtpDataType.Binary, bool checkIfFileExists = true, CancellationToken token = default(CancellationToken)) { + return OpenWriteAsync(path, type, checkIfFileExists ? 0 : -1, token); + } + /// /// Opens the specified file for writing. Please call GetReply() after you have successfully transfered the file to read the "OK" command sent by the server and prevent stale data on the socket. /// @@ -1486,6 +1383,7 @@ public virtual Stream OpenWrite(string path, FtpDataType type, long fileLen) { /// /// The token that can be used to cancel the entire process /// A stream for writing to the file on the server + [Obsolete("OpenWriteAsync() is obsolete, please use UploadAsync() or UploadFileAsync() instead", false)] public virtual async Task OpenWriteAsync(string path, FtpDataType type, long fileLen, CancellationToken token = default(CancellationToken)) { // verify args if (path.IsBlank()) { @@ -1522,63 +1420,12 @@ public virtual Stream OpenWrite(string path, FtpDataType type, long fileLen) { return stream; } - /// - /// Opens the specified file for writing. Please call GetReply() after you have successfully transfered the file to read the "OK" command sent by the server and prevent stale data on the socket. - /// - /// Full or relative path of the file - /// ASCII/Binary - /// Only set this to false if you are SURE that the file does not exist. If true, it reads the file size and saves it into the stream length. - /// The token that can be used to cancel the entire process - /// A stream for writing to the file on the server - public virtual Task OpenWriteAsync(string path, FtpDataType type, bool checkIfFileExists, CancellationToken token = default(CancellationToken)) { - return OpenWriteAsync(path, type, checkIfFileExists ? 0 : -1, token); - } - - /// - /// Opens the specified file for writing. Please call GetReply() after you have successfully transfered the file to read the "OK" command sent by the server and prevent stale data on the socket. asynchronously - /// - /// Full or relative path of the file - /// ASCII/Binary - /// The token that can be used to cancel the entire process - /// A stream for writing to the file on the server - public Task OpenWriteAsync(string path, FtpDataType type, CancellationToken token = default(CancellationToken)) { - return OpenWriteAsync(path, type, 0, token); - } - - /// - /// Opens the specified file for writing. Please call GetReply() after you have successfully transfered the file to read the "OK" command sent by the server and prevent stale data on the socket. asynchronously - /// - /// Full or relative path of the file - /// The token that can be used to cancel the entire process - /// A stream for writing to the file on the server - public Task OpenWriteAsync(string path, CancellationToken token = default(CancellationToken)) { - return OpenWriteAsync(path, FtpDataType.Binary, 0, token); - } #endif #endregion #region Open Append - /// - /// Opens the specified file for appending. Please call GetReply() after you have successfully transfered the file to read the "OK" command sent by the server and prevent stale data on the socket. - /// - /// The full or relative path to the file to be opened - /// A stream for writing to the file on the server - public Stream OpenAppend(string path) { - return OpenAppend(path, FtpDataType.Binary, 0); - } - - /// - /// Opens the specified file for appending. Please call GetReply() after you have successfully transfered the file to read the "OK" command sent by the server and prevent stale data on the socket. - /// - /// The full or relative path to the file to be opened - /// ASCII/Binary - /// A stream for writing to the file on the server - public virtual Stream OpenAppend(string path, FtpDataType type) { - return OpenAppend(path, type, 0); - } - /// /// Opens the specified file for appending. Please call GetReply() after you have successfully transfered the file to read the "OK" command sent by the server and prevent stale data on the socket. /// @@ -1586,7 +1433,8 @@ public virtual Stream OpenAppend(string path, FtpDataType type) { /// ASCII/Binary /// Only set this to false if you are SURE that the file does not exist. If true, it reads the file size and saves it into the stream length. /// A stream for writing to the file on the server - public virtual Stream OpenAppend(string path, FtpDataType type, bool checkIfFileExists) { + [Obsolete("OpenAppend() is obsolete, please use UploadFile() with FtpRemoteExists.Resume or FtpRemoteExists.AddToEnd instead", false)] + public virtual Stream OpenAppend(string path, FtpDataType type = FtpDataType.Binary, bool checkIfFileExists = true) { return OpenAppend(path, type, checkIfFileExists ? 0 : -1); } @@ -1602,6 +1450,7 @@ public virtual Stream OpenAppend(string path, FtpDataType type, bool checkIfFile ///
>0 => File length is KNOWN. No need to determine it
/// /// A stream for writing to the file on the server + [Obsolete("OpenAppend() is obsolete, please use UploadFile() with FtpRemoteExists.Resume or FtpRemoteExists.AddToEnd instead", false)] public virtual Stream OpenAppend(string path, FtpDataType type, long fileLen) { // verify args if (path.IsBlank()) { @@ -1647,6 +1496,19 @@ public virtual Stream OpenAppend(string path, FtpDataType type, long fileLen) { } #if ASYNC + /// + /// Opens the specified file to be appended asynchronously + /// + /// Full or relative path of the file + /// ASCII/Binary + /// Only set this to false if you are SURE that the file does not exist. If true, it reads the file size and saves it into the stream length. + /// The token that can be used to cancel the entire process + /// A stream for writing to the file on the server + [Obsolete("OpenAppendAsync() is obsolete, please use UploadFileAsync() with FtpRemoteExists.Resume or FtpRemoteExists.AddToEnd instead", false)] + public virtual Task OpenAppendAsync(string path, FtpDataType type = FtpDataType.Binary, bool checkIfFileExists = true, CancellationToken token = default(CancellationToken)) { + return OpenAppendAsync(path, type, checkIfFileExists ? 0 : -1, token); + } + /// /// Opens the specified file to be appended asynchronously /// @@ -1660,6 +1522,7 @@ public virtual Stream OpenAppend(string path, FtpDataType type, long fileLen) { /// /// The token that can be used to cancel the entire process /// A stream for writing to the file on the server + [Obsolete("OpenAppendAsync() is obsolete, please use UploadFileAsync() with FtpRemoteExists.Resume or FtpRemoteExists.AddToEnd instead", false)] public virtual async Task OpenAppendAsync(string path, FtpDataType type, long fileLen, CancellationToken token = default(CancellationToken)) { // verify args if (path.IsBlank()) { @@ -1698,38 +1561,6 @@ public virtual Stream OpenAppend(string path, FtpDataType type, long fileLen) { return stream; } - /// - /// Opens the specified file to be appended asynchronously - /// - /// Full or relative path of the file - /// ASCII/Binary - /// Only set this to false if you are SURE that the file does not exist. If true, it reads the file size and saves it into the stream length. - /// The token that can be used to cancel the entire process - /// A stream for writing to the file on the server - public virtual Task OpenAppendAsync(string path, FtpDataType type, bool checkIfFileExists, CancellationToken token = default(CancellationToken)) { - return OpenAppendAsync(path, type, checkIfFileExists ? 0 : -1, token); - } - - /// - /// Opens the specified file to be appended asynchronously - /// - /// Full or relative path of the file - /// ASCII/Binary - /// The token that can be used to cancel the entire process - /// A stream for writing to the file on the server - public Task OpenAppendAsync(string path, FtpDataType type, CancellationToken token = default(CancellationToken)) { - return OpenAppendAsync(path, type, 0, token); - } - - /// - /// Opens the specified file to be appended asynchronously - /// - /// Full or relative path of the file - /// The token that can be used to cancel the entire process - /// A stream for writing to the file on the server - public Task OpenAppendAsync(string path, CancellationToken token = default(CancellationToken)) { - return OpenAppendAsync(path, FtpDataType.Binary, 0, token); - } #endif #endregion diff --git a/FluentFTP/Client/IFtpClient.cs b/FluentFTP/Client/IFtpClient.cs index f77992b01..d370e1837 100644 --- a/FluentFTP/Client/IFtpClient.cs +++ b/FluentFTP/Client/IFtpClient.cs @@ -203,38 +203,20 @@ public interface IFtpClient : IDisposable { // LOW LEVEL - Stream OpenRead(string path); - Stream OpenRead(string path, FtpDataType type); - Stream OpenRead(string path, FtpDataType type, bool checkIfFileExists); - Stream OpenRead(string path, FtpDataType type, long restart); - Stream OpenRead(string path, long restart); - Stream OpenRead(string path, long restart, bool checkIfFileExists); - Stream OpenRead(string path, FtpDataType type, long restart, bool checkIfFileExists); + Stream OpenRead(string path, FtpDataType type = FtpDataType.Binary, long restart = 0, bool checkIfFileExists = true); Stream OpenRead(string path, FtpDataType type, long restart, long fileLen); - Stream OpenWrite(string path); - Stream OpenWrite(string path, FtpDataType type); - Stream OpenWrite(string path, FtpDataType type, bool checkIfFileExists); + Stream OpenWrite(string path, FtpDataType type = FtpDataType.Binary, bool checkIfFileExists = true); Stream OpenWrite(string path, FtpDataType type, long fileLen); - Stream OpenAppend(string path); - Stream OpenAppend(string path, FtpDataType type); - Stream OpenAppend(string path, FtpDataType type, bool checkIfFileExists); + Stream OpenAppend(string path, FtpDataType type = FtpDataType.Binary, bool checkIfFileExists = true); Stream OpenAppend(string path, FtpDataType type, long fileLen); #if ASYNC + Task OpenReadAsync(string path, FtpDataType type = FtpDataType.Binary, long restart = 0, bool checkIfFileExists = true, CancellationToken token = default(CancellationToken)); Task OpenReadAsync(string path, FtpDataType type, long restart, long fileLen, CancellationToken token = default(CancellationToken)); - Task OpenReadAsync(string path, FtpDataType type, long restart, bool checkIfFileExists, CancellationToken token = default(CancellationToken)); - Task OpenReadAsync(string path, FtpDataType type, long restart, CancellationToken token = default(CancellationToken)); - Task OpenReadAsync(string path, FtpDataType type, CancellationToken token = default(CancellationToken)); - Task OpenReadAsync(string path, long restart, CancellationToken token = default(CancellationToken)); - Task OpenReadAsync(string path, CancellationToken token = default(CancellationToken)); + Task OpenWriteAsync(string path, FtpDataType type = FtpDataType.Binary, bool checkIfFileExists = true, CancellationToken token = default(CancellationToken)); Task OpenWriteAsync(string path, FtpDataType type, long fileLen, CancellationToken token = default(CancellationToken)); - Task OpenWriteAsync(string path, FtpDataType type, bool checkIfFileExists, CancellationToken token = default(CancellationToken)); - Task OpenWriteAsync(string path, FtpDataType type, CancellationToken token = default(CancellationToken)); - Task OpenWriteAsync(string path, CancellationToken token = default(CancellationToken)); + Task OpenAppendAsync(string path, FtpDataType type = FtpDataType.Binary, bool checkIfFileExists = true, CancellationToken token = default(CancellationToken)); Task OpenAppendAsync(string path, FtpDataType type, long fileLen, CancellationToken token = default(CancellationToken)); - Task OpenAppendAsync(string path, FtpDataType type, bool checkIfFileExists, CancellationToken token = default(CancellationToken)); - Task OpenAppendAsync(string path, FtpDataType type, CancellationToken token = default(CancellationToken)); - Task OpenAppendAsync(string path, CancellationToken token = default(CancellationToken)); #endif