Post a reply

Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)


Topic review


Hi I found the solution and its working fine for me.

I used session.ListDirectory("/+recfm=fb,lrecl=2214,blksize=0,replace/");
to create file with record length of 2214 in mainframe. I am not getting "Cannot overwrite remote file "FineName".$$" error when I used "/replace" in session.ListDirectory().

Attached log file as private.

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.

Hi Tried using this but getting error.
Cannot overwrite remote file "FineName".$$
Press 'Delete' to delete the file and create new one instead of overwriting it.$$
And also, even after error, it is creating file on server but with no data.

Below is the code that I used.
SessionOptions sessionOptions = new SessionOptions
Protocol = Protocol.Sftp,
HostName = "ServeName",
UserName = "Userid",
SshHostKeyFingerprint = "------------",
SshPrivateKeyPath = @"----------------",
sessionOptions.AddRawSettings("FSProtocol", "2");
sessionOptions.AddRawSettings("CacheDirectories", "0");
sessionOptions.AddRawSettings("CacheDirectoryChanges", "0");

using (Session session = new Session())
TransferOptions transferOptions = new TransferOptions
{ TransferMode = TransferMode.Automatic, };

session.PutFiles(sourcepath, cpedFilename, false, transferOptions).Check();

If I am removing session.ListDirectory("/+lrecl=35"); and
then it is creating file with data but of record length 128.

Let me know if I am doing anything wrong.

You can use:


I see that in command we can specify it as sftp> ls /+lrecl=255. but in .net assembly code I am not getting how to specify.

Hi, Thanks for replying. While using ftp protocol, I didn't specify any record length. At my end length of record is 2214 and while doing session.put() record length is same. But when I am using sftp protocol, my line is breaking at 100 length and going to next line. Not sure if I have to set any attribute?

Re: specify record lenth while sftp to mainframe in .net code

There's no "record length" in SFTP. If your mainframe SFTP server supports that, it must be some kind of a hack or a proprietary feature. If you provide us any documentation about that, we can help you with setting it up in WinSCP. Are you able to specify the record length in any other SFTP client?

specify record lenth while sftp to mainframe in .net code

Hi, I am transferring file to mainframe server using WinSCP sftp .net code. I have to specify record length while transferring file. At my end record length is 2214 but when I am transferring file it is creating file with 100 length. I tried all transfer modes ASCII, Automatic and Binary. When I was using ftp protocol with ASCII, it used to create file with same record length of 2214. but with sftp I am facing this issue.