PutFileToDirectory fails with []

Advertisement

Speed103
Joined:
Posts:
6
Location:
Lafayette, LA

PutFileToDirectory fails with []

I'm trying to use the PutFileToDirectory method in my C# program. However, it fails on files with square brackets in the name, like Test[4]. I assumed it was a filemask issue but I can't use RemotePath.EscapeFileMask because it only takes the original filename and then the remote directory. Also, the documentation seems to indicate:
You specify a path to the source file, not a wildcard, so you do not need to escape a literal file name.
Is this is a bug or am I missing something I need to set to send these files?

Thanks!

Reply with quote

Advertisement

Speed103
Joined:
Posts:
6
Location:
Lafayette, LA

FYI...here's an example exception when trying to execute:
ftpSession.PutFileToDirectory(@"C:\Temp\test[4].txt", "/");
I get:
Unhandled Exception: WinSCP.SessionRemoteException: File or folder 'C:\Temp\test[[]4].txt' does not exist.
If I manually call RemotePath.EscapeFileMask(filename), it appears it converts my filename to the name in the exception, so I'm thinking PutFileToDirectory automatically calls that on the local file parameter, but is not escaping correctly with square brackets?

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
35,438
Location:
Prague, Czechia

Re: PutFileToDirectory fails with []

Thanks for your report.

This bug has been added to the tracker:
https://winscp.net/tracker/1931

I'm sending you an email with a development version of WinSCP to the address you have used to register on this forum.

Reply with quote

Speed103

The fix worked. I assume it will take a while to make it into the NuGet repo? I worked around it by using PutFiles but would like to change it back to PutFileToDirectory when I can since the syntax is simpler as your documentation has noted.

Reply with quote

Advertisement

Manurobate
Joined:
Posts:
1
Location:
France

Hi there,

I have exactly the same probleme. Could you please send me the development version of WinSCP to fix my problem ?

If not, do you know when the fix will be release ?

Thanks for your help.

Reply with quote

martin
Site Admin
martin avatar

Manurobate wrote:

I have exactly the same probleme. Could you please send me the development version of WinSCP to fix my problem ?
I'm sending you an email with a development version of WinSCP to the address you have used to register on this forum.

Reply with quote

Advertisement

You can post new topics in this forum