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

Advertisement

ankitmehta84
Joined:
Posts:
4
Location:
New York

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

Reply with quote

Advertisement

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

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.

Reply with quote

Advertisement

You can post new topics in this forum