Topic ".Net assembly error trying to put a file. I get error "Ascii, Binary or Automatic is not supported?"

Author Message
KenMejias
[View user's profile]

Joined: 2017-02-03
Posts: 2
Location: Va. beach, Va.
Hello.
I am using the latest .Net assembly (Btw Thanks for this great product!)
I can get a session connected with SFTP, I can create destination folders, but when I try to PUT files I get an error stating none of the TransferMode's work? I've tried Binary, Ascii and Automatic. Same thing each setting. Using the WinSCP app itself I can use same credentials and keys/fingerprints and get logged in and then I can create Dirs, Read, Write, Delete files. No problem with permissions. This is a prod account and works. We use WinSCP all day long here. I am just trying to automate it.
I just can't figure this out. Any help would be greatly appreciated.

My setup:
Windows 7 enterprise. Visual Studio 2015 all new installs.
Connecting to pretty recent version of OpenBSD SSHd on Windows Server. It is a production server and moves 1000's of files a day so it's probably good to go.
Logs attached.

Code sample: (simplified to read)
Try
' Setup session options
Dim sessionOptions As New SessionOptions

With sessionOptions
.Protocol = Protocol.Sftp
.PortNumber = Trim(txtPort.Text)
.HostName = Trim(txtserverAddr.Text)
.UserName = Trim(TxtLogin.Text)
.SshPrivateKeyPath = Trim(TxtKeyPath.Text)
.SshHostKeyFingerprint = Trim(My.Settings.FingerPrint)
End With

Using session As New Session
session.DebugLogPath = My.Settings.MkInt_RootDir & "\Debug.log"
session.SessionLogPath = My.Settings.MkInt_RootDir & "\Session.Log"

session.Open(sessionOptions)
' Upload files
Dim transferOptions As New TransferOptions
transferOptions.TransferMode = TransferMode.Automatic (Ascii and Binary fail as well)
transferOptions.PreserveTimestamp = False
transferOptions.OverwriteMode = True

Dim transferResult As TransferOperationResult
Dim XFilenames string = "SomeFileName.txt"
Dim DestFilenames As String = "SomeFileName.txt"
Log("Creating Vendor folders on MFTPROD\CLIENT\ area if needed..")
session.DebugLogLevel = 1

session.CreateDirectory("111"))
session.CreateDirectory("111/VendorFolder")
Log("Destination folders Exists - Ok.")

'FAILS HERE. Jumps to 'END USING' statement after about 2 seconds
transferResult = session.PutFiles(XFilenames, DestFilenames, True, transferOptions)

'Throw On any Error
transferResult.Check()
For Each transfer In transferResult.Transfers
rTxtConsole.AppendText("Upload of {0} succeeded" & transfer.FileName)
Next
session.Close()

End Using

Catch ex As Exception
Me.StatusStrip1.Text = "Error Occured.."
Me.StatusStrip1.BackColor = Color.Red
rTxtConsole.AppendText("Error: " & ex.Message & vbCrLf)

End Try

results from my logging window:

Files are ready to deploy...

Beginning Connect Attempt..
Connect Opened, Creating Folders and transferring files..
Creating Vendor folders on MFTPROD\CLIENT\ area if needed..
Creating 111\vendorfolder
Destination folders Created/Exists - Ok.

Moving files C:\MkInterface\rci_sqrname_X*.* to /111/vendorfolder/rci_sqrname_X*.*

Error: Ascii is not supported

I also get "Binary is not supported" and "Automatic is not supported."

Thank you for any help you can provide.
Session.Log (10.48 KB) [Download]

Description: (none)

Debug.log (80.45 KB) [Download]

Description: (none)

Advertisements
martin◆
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26705
Location: Prague, Czechia
The error message is wrong.
It's actually the OverwriteMode value that is wrong. It cannot be set to a Boolean (True). It's an enumeration.
https://winscp.net/eng/docs/library_transferoptions#overwritemode
KenMejias
[View user's profile]

Joined: 2017-02-03
Posts: 2
Location: Va. beach, Va.
martin wrote:
The error message is wrong.
It's actually the OverwriteMode value that is wrong. It cannot be set to a Boolean (True). It's am enumeration.
https://winscp.net/eng/docs/library_transferoptions#overwritemode


That was it. Thank you for pointing that out Martin. I really appreciate the quick reply. Smile
martin◆
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26705
Location: Prague, Czechia
This issue has been added to the tracker:
https://winscp.net/tracker/show_bug.cgi?id=1504
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