add call to GetReply after using OpenRead or OpenWrite according to FluentFTP documentation

This commit is contained in:
Olle Kelderman 2018-03-23 17:46:29 +01:00
parent a796eba0fc
commit 07e3bf3311

View file

@ -231,10 +231,7 @@ public bool UploadData(Stream localStream, string remotePath)
{
try
{
using (Stream remoteStream = client.OpenWrite(remotePath))
{
return TransferData(localStream, remoteStream);
}
return UploadData2(localStream, remotePath);
}
catch (FtpCommandException e)
{
@ -243,10 +240,7 @@ public bool UploadData(Stream localStream, string remotePath)
{
CreateMultiDirectory(URLHelpers.GetDirectoryPath(remotePath));
using (Stream remoteStream = client.OpenWrite(remotePath))
{
return TransferData(localStream, remoteStream);
}
return UploadData2(localStream, remotePath);
}
throw e;
@ -256,6 +250,17 @@ public bool UploadData(Stream localStream, string remotePath)
return false;
}
private bool UploadData2(Stream localStream, string remotePath)
{
bool result;
using (Stream remoteStream = client.OpenWrite(remotePath))
{
result = TransferData(localStream, remoteStream);
}
FtpReply ftpReply = client.GetReply();
return result && ftpReply.Success;
}
public void UploadData(byte[] data, string remotePath)
{
using (MemoryStream stream = new MemoryStream(data, false))
@ -322,6 +327,7 @@ public void DownloadFile(string remotePath, Stream localStream)
{
TransferData(remoteStream, localStream);
}
client.GetReply();
}
}