FluentFTP icon indicating copy to clipboard operation
FluentFTP copied to clipboard

GetListing() does not work with square brackets

Open lanopk opened this issue 8 years ago • 4 comments

Sorry. I did wrong testing. Updated.

When I use foldername has '[]', FluentFtp GetListing() function returns 1 item and item is self foldername. Ftp Server : Synology Client : Windows 10, .Net 4.5.2, FluentFtp 17.2.0

for example, (1) [].folder is empty folder. ftp.connect(); ftp.SetWorkingDirectory("/Temp/[].folder"); FtpListItem[] list = ftp.GetListing();

result : list.Count => 1 list[0].Name => [].folder list[0].Fullname => /Temp/[].folder/[].folder

*FtpListItem[] list = ftp.GetListing("/Temp/[].folder"); => same result. *WinSCP ftp Client works good.

(2) if filename has '[]', GetObjectInfo returns parent folder info.

Thank you for your help.

lanopk avatar May 16 '17 02:05 lanopk

In my case, to avoid square brackets problem, use SetWorkingDirectory and GetList with NoPath option.

// example codes FtpClient ftp = ...;

string ftppath = "[].folder"; //string ftppath = "[a].folder";

FtpListItem[] list = null; if (path.Contains("[") && path.Contains("]")) { ftp.SetWorkingDirectory(ftppath); list = ftp.GetListing(null, FtpListOption.NoPath); } else { list = ftp.GetListing(ftppath); }

lanopk avatar Jun 30 '17 06:06 lanopk

i have this problem too. and i used almost same workaround.

heebaek avatar Aug 05 '17 06:08 heebaek

Same error

damob-byun avatar Apr 23 '20 07:04 damob-byun

In my case

use this code

client.SetWorkingDirectory("/");

I solved

damob-byun avatar Apr 23 '20 08:04 damob-byun

Works in V.40

using

FTP_Sess.SetWorkingDirectory("/home/mike");
FtpListItem[] Items = FTP_Sess.GetListing("", FtpListOption.ForceList | FtpListOption.NoPath);

you get

Fullname: "/home/mike/[].folder"
Name: "[].folder"

FanDjango avatar Sep 19 '22 14:09 FanDjango

See Wiki path problems

FanDjango avatar Sep 19 '22 15:09 FanDjango