This project is read-only.

Deleting files in subfolders

Mar 13, 2012 at 4:20 PM

Hey, I'm trying to delete a file that's contained within a subfolder located on an FTP site.  I'm trying to use the DeleteFile method, but I keep getting a "File not found" error.

First I started with the plain call:


But this gave me the "File not found error".  So then I thought I needed to change my remote active folder, so I tried the following:


But I get the same "File not found" error.  

Any help identifying what I'm doing wrong would be greatly appreciated!

Cheers, Jon 

Mar 13, 2012 at 4:28 PM

What do you get if you do sftpClient.Get.

Also, since you using / in the beginning it assumes root path,

What happens if you run cat /TESTFOLDER/FileToDelete.txt command on unix box?




Mar 13, 2012 at 5:01 PM

Thanks, Oleg, for getting back to me.  When I do an sftpClient.Get and supply the full path of the file on the FTP site (in this case it's "/TEST/FileToDelete.txt"), I get back the file information.

As a test, I moved the file to the root folder, and tried deleting it and I get the same error message.  I tried both


and just


I'm working in a Windows shop, so I don't have easy access to a unix box.

Hope that helps! Jon 

Mar 13, 2012 at 5:26 PM

Oleg, I did a little more testing, and it appear that it's a permissions issue.  I logged into the site using WinSCP, and attempted to delete the file, and the FTP site returned a "File not found" error to WinSCP.  So much for a helpful error message.

Anyway, it looks like the framework is working correctly, and passing back the returned error message from the server.

Sorry for the confusion, and I appreciate your help!  The framework is pretty easy to use and is reliable. :)

Cheers, Jon