Topic "WinSCP.SessionRemoteException: Error transferring file"

Author Message
Amit

Guest


Hi,

In the .net application that we are using, we are getting the error as shown below.
Please help us resolve it asap.

CODE:=======================================================================
using (Session objSession = new Session())
{
objSession.ExecutablePath = winScpExeWithPath;

// Connect
objSession.Open(objSessionOptions);

// Upload files
TransferOptions objTransferOptions = new TransferOptions();
objTransferOptions.TransferMode = TransferMode.Binary;

TransferOperationResult transferResult = objSession.PutFiles(localPath, FTPFolder, false, objTransferOptions);
// Transfer result
if (!transferResult.IsSuccess)
{
WriteLog("File transfer error: " + transferResult.Transfers[0].Error + Environment.NewLine + "Details:" + Environment.NewLine + (((System.Exception)(transferResult.Transfers[0].Error)).InnerException).Message);
return false;
}
else
{
return true;
}
}
ERROR LOG:=======================================================================
File transfer error: WinSCP.SessionRemoteException: Error transferring file 'C:\India-Dev\EMEA\NetSearch\EBTA Service\trunk\EBTAAmexUpload\TEST\AmexUpload\FileUpload\IM1I50EBA'. ---> WinSCP.SessionRemoteException: Copying files to remote side failed.
Access is denied.
Win32 error: Access is denied.
Error details: File system denied the access.
End
--- End of inner exception stack trace ---
Details:
Copying files to remote side failed.
Access is denied.
Win32 error: Access is denied.
Error details: File system denied the access.
End
Advertisements
martin◆
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26911
Location: Prague, Czechia
Quote:
Error transferring file 'C:\India-Dev\EMEA\NetSearch\EBTA Service\trunk\EBTAAmexUpload\TEST\AmexUpload\FileUpload\IM1I50EBA'. ---> WinSCP.SessionRemoteException: Copying files to remote side failed.
Access is denied.
Win32 error: Access is denied.
Error details: File system denied the access.


The local account that runs your code does not have an access to the file you want to upload.
Amit

Guest


I have verified that all permissions are okay. Am I missing anything?
Could you please assist in what else I can check?

Thanks.

martin wrote:
Quote:
Error transferring file 'C:\India-Dev\EMEA\NetSearch\EBTA Service\trunk\EBTAAmexUpload\TEST\AmexUpload\FileUpload\IM1I50EBA'. ---> WinSCP.SessionRemoteException: Copying files to remote side failed.
Access is denied.
Win32 error: Access is denied.
Error details: File system denied the access.


The local account that runs your code does not have an access to the file you want to upload.
Amit

Guest


Hi,

Your quick response is appreciated. I have tried what you suggested, but still the issue is there.

martin wrote:
Quote:
Error transferring file 'C:\India-Dev\EMEA\NetSearch\EBTA Service\trunk\EBTAAmexUpload\TEST\AmexUpload\FileUpload\IM1I50EBA'. ---> WinSCP.SessionRemoteException: Copying files to remote side failed.
Access is denied.
Win32 error: Access is denied.
Error details: File system denied the access.


The local account that runs your code does not have an access to the file you want to upload.
martin◆
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26911
Location: Prague, Czechia
If you need more help, you need to tell us something about your environment. How do you run the code?
Amit

Guest


martin wrote:
If you need more help, you need to tell us something about your environment. How do you run the code?


As of now, I run the code locally on my local machine for testing, using Visual Studio IDE and I have checked in code that it runs on the windows identity/account to which I have already given permissions on the required folders/files for FTP transfer.

Please let me know if you need more information.
martin◆
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26911
Location: Prague, Czechia
Please attach a full session log file showing the problem (using the latest version of WinSCP).

To generate the session log file, set Session.SessionLogPath. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you can mark the attachment as private.
Amit

Guest


martin wrote:
Please attach a full session log file showing the problem (using the latest version of WinSCP).

To generate the session log file, set Session.SessionLogPath. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you can mark the attachment as private.


Please review attached log file as you requested, and let us know your observations and resolution based on that.
Please let us know if any more information is required from our end.


Thanks.
SessionLog20170220_ToWinSCP.txt (8.3 KB) Private file

Description: File attached: SessionLog20170220_ToWinSCP.txt

martin◆
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26911
Location: Prague, Czechia
OK, so your server runs on Windows. That's why the error message looked like local, while it was actually remote. So my advice above were indeed wrong.

The actual problem is that you probably miss a slash at the end of the target path.
The FTPFolder should be /inbox/.
Amit

Guest


martin wrote:
OK, so your server runs on Windows. That's why the error message looked like local, while it was actually remote. So my advice above were indeed wrong.

The actual problem is that you probably miss a slash at the end of the target path.
The FTPFolder should be /inbox/.


Thanks a lot.
Amit

Guest


Hi,

We were able to do a successful test on local machine using FTP.
However, we are facing issues using SFTP on production. Please see details below. Please note that we have already supplied Ssh Host Key Fingerprint which is required for SFTP.

Application error details==============================
Process : ConnectToServerAndUploadFile : Message - Connection has been unexpectedly closed. Server sent command exit status 0. [StackTrace - at WinSCP.SessionLogReader.Read(LogReadFlags flags)
at WinSCP.ElementLogReader.Read(LogReadFlags flags)
at WinSCP.SessionElementLogReader.Read(LogReadFlags flags)
at WinSCP.CustomLogReader.TryWaitForNonEmptyElement(String localName, LogReadFlags flags)
at WinSCP.CustomLogReader.WaitForNonEmptyElement(String localName, LogReadFlags flags)
at WinSCP.CustomLogReader.WaitForGroupAndCreateLogReader()
at WinSCP.Session.Open(SessionOptions sessionOptions)
at EBTAAmexUpload.Process.ConnectToServerAndUploadFile(String localPath, String winScpExeWithPath, String sessionLogPath)]
=======================================================

Please see attached SessionLog20170314.txt - WinSCP session log file of relevant test - for your reference.


Thanks & Regards.

Amit wrote:
martin wrote:
OK, so your server runs on Windows. That's why the error message looked like local, while it was actually remote. So my advice above were indeed wrong.

The actual problem is that you probably miss a slash at the end of the target path.
The FTPFolder should be /inbox/.


Thanks a lot.
SessionLog20170314.txt (5.86 KB) Private file

Description: SessionLog20170314.txt attached

martin◆
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26911
Location: Prague, Czechia
It does not look like, you have attached the log, for the session, that have the "Connection has been unexpectedly closed. Server sent command exit status 0." error.

In the log, I can only see "Access denied" .. "Disconnected: Unable to authenticate", because you are probably using wrong credentials.
Advertisements

You can post new topics in this forum

Search

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License