Trailing Spaces in Directory Names

Advertisement

remopini
Joined:
Posts:
8
Location:
Switzerland

Trailing Spaces in Directory Names

Hi all

Since this works in Filezilla but not in WinSCP, I assume it is a bug:

I have a NAS (QNAP) with an FTP server on it. Since the NAS is used by OSX machines, users tend to put all different kinds of crap in their filenames (which I hate, but it is what it is...).

I'm using the .NET component to write my own sync script (to get various files from the FTP server and save them locally on a regular basis).

This works fine unless either the filename or a directory name has one or more trailing whitespaces. The problem is (it seems), that Session.ListDirectory(path) fails if the path ends in whitespaces. Also any returned RemoteFileInfo items seem to be stripped of trailing whitespaces, too, even though in FileZilla listings, they are clearly there.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,440
Location:
Prague, Czechia

Re: Trailing Spaces in Directory Names

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.

Reply with quote

remopini
Joined:
Posts:
8
Location:
Switzerland

The folder in question is:
(Filezilla) Status: Directory listing of "/projekte/zJobs 2019/159. Gerber Fondue (Gifs)/3. Produktion/04. Castings/01. Darsteller/Casting BETH UK Hero " successful

Note the extra space (or tab or whatever it is) at the end of the directory name.

Reply with quote

Advertisement

remopini

Great!
Works as a standalone app with that directory now.
Any chance you can send me an updated .net assembly so I can test it programmatically? It won't accept the new WinSCP because of a version mismatch.

Reply with quote

remopini
Joined:
Posts:
8
Location:
Switzerland

Great thx!
Got a new error now:
directory = ftpsession.ListDirectory(ftppath)
throws an error if ftppath ends with a space. The space seems to get removed automatically and the result is an Exception:
Error listing directory ... : No such file or directory

ftppath was just extracted from a previous RemoteFileInfo from a .ListDirectory collection.

It seems that ListDirectory removes trailing spaces before running the actual command?

Reply with quote

Advertisement

remopini
Joined:
Posts:
8
Location:
Switzerland

WinSCP.SessionRemoteException
HResult=0x80131500
Message=Error listing directory '///projekte/zJobs 2019/159. Gerber Fondue (Gifs)/3. Produktion/04. Castings/01. Darsteller/Casting BETH UK Hero '.
Could not retrieve directory listing
/projekte/zJobs 2019/159. Gerber Fondue (Gifs)/3. Produktion/04. Castings/01. Darsteller/Casting BETH UK Hero: No such file or directory
Source=WinSCPnet
StackTrace:
at WinSCP.SessionLogReader.Read(LogReadFlags flags)
at WinSCP.ElementLogReader.Read(LogReadFlags flags)
at WinSCP.SessionElementLogReader.Read(LogReadFlags flags)
at WinSCP.ElementLogReader.Read(LogReadFlags flags)
at WinSCP.CustomLogReader.TryWaitForNonEmptyElement(String localName, LogReadFlags flags)
at WinSCP.CustomLogReader.WaitForNonEmptyElement(String localName, LogReadFlags flags)
at WinSCP.Session.ListDirectory(String path)
at ChocSync.MainWindow.GetDirectory(BackgroundWorker worker, String ftppath, ITree`1 tree, INode`1 node, Session ftpsession, Int32 level)

Reply with quote

Advertisement

You can post new topics in this forum