This project is read-only.

Delete File Not Deleting

Sep 14, 2011 at 2:27 PM

I'm unable to delete a file on the remote FTP server using the project. I believe the root cause is that the FullName property of the File object is not getting populated, which is used by the Delete method.

Here's the code sample:

            foreach (FTPSource ftp in FTPSourceConfig.GetConfig().FTPSources)
            {
                //ftplib documented and source available at https://ftplib.codeplex.com/
                using (FtpConnection ftpConn = new FtpConnection(ftp.FTPAddress, ftp.FTPUserName, ftp.FTPPassword))
                {
                    ftpConn.Open();
                    ftpConn.Login();
                    foreach (var file in ftpConn.GetFiles())
                    {
                        ftpConn.GetFile(file.Name, Path.Combine(ftp.LocalDirectoryToCopyTo, file.Name), false);
                        file.Delete();
                    }
                    ftpConn.Close();
                }
            }

The GetFile call works properly, but the on the next line fails. Any thoughts?

Coordinator
Sep 20, 2011 at 5:43 PM
Edited Sep 20, 2011 at 5:44 PM

I believe you are correct. However, I don't have the ability to test right now. You should be able to change the constructor and add 

base.FullName = filepath;