0 votes
by (120 points)

I've got a Xamarin app built with VisualStudio 2022 and running on an Android R device. I'm pulling the libraries into my project using NuGet and setting the correct license in code.

Here's the function that's getting an error:

public void UploadFile(string localFileName, string remoteFileName)
{
try
{
if (Login())
{
mSFTP.Settings.EnableBrokenDirectoryStatWorkaround = true;
String[] split = remoteFileName.Split(new Char[] { '/' });
m
SFTP.ChangeDirectory(split[0]);
mTransferInProgress = true;
m
SFTP.PutFile(localFileName, split[1]);
}
}
catch (SftpException ex)
{
ThrowAnException(ex, UlSftpTransferType.Upload, localFileName, remoteFileName);
}
finally
{
m_TransferInProgress = false;
}
}

The local pathname exists and is accessible. The remote directory exists and the call to ChangeDirectory() succeeds. The call to PutFile(), though, returns an exception:

ex {Rebex.Net.SftpException} Rebex.Net.SftpException
base {Rebex.Net.NetworkSessionException} Rebex.Net.NetworkSessionException
Code Rebex.Net.SftpErrorCode.NoSuchFile Rebex.Net.SftpErrorCode
LocalPath (null) string
ProblemType 0 Rebex.IO.TransferProblemType
RemotePath (null) string
Status Rebex.Net.SftpExceptionStatus.ProtocolError Rebex.Net.SftpExceptionStatus
Transferred 0 long

This was occurring with the previous version of Rebex (R5.1) and is still occurring with version 7.0.8816.

I added the line of code to set EnableBrokenDirectoryStatWorkaround as per another suggestion I found but that doesn't appear to work.

Any ideas what this exception means and how I can correct the problem? Thanks.

Applies to: Rebex SFTP

1 Answer

0 votes
by (144k points)
This does not seem to be a Rebex issue. The server just seems to be reporting a misleading error code. To determine what is going on, please create a communication log - as described at https://www.rebex.net/kb/logging/ - and post it here or mail it to us for analysis. It might also be useful to try running the equivalent SFTP code on a PC - most likely, the same error would occur if you tried the same action, and it might be easier to debug this on the PC than on an Android device.
...