Post a reply

Options
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)

Options

Topic review

martin

Re: Delete Files with with empty spaces in File name using WinSCPNet.dll

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.
ankitmehta84

Delete Files with with empty spaces in File name using WinSCPNet.dll

When I try to run the below code where I am trying to delete file with empty space in the name:

Session session = new Session();

SessionOptions sessionOptions = CreateSession(session, hostname, userName, password, timeout);
session.Open(sessionOptions);
var result = session.RemoveFiles(@"/testspac/error 2.txt");
return result;


It gives me the following error:

{"Can't get attributes of file '/testspac/error 2.txt'.\r\nNo such file or directory.\nError code: 2\nError message from server (en): No such file"}

I am not sure how to escape the spaces. I tried wrapping the full path in double quotes and that gave me the same error. I also tried replacing the space with %20 and that did not work too. I am using WinSCPnet.dll version 5.9.1 and file version 1.3.4.6885.
Any pointers would be helpful.

Thanks