ComponentPro UltimateFtp

      Delete files and directories

      Language Filter: AllSend comments on this topic to ComponentPro

      To delete multiple files, use the Delete. The methods require the path to the remote directory containing entries to delete as the first parameter. The following illustrates how to use the Delete to delete multiple files.

      To understand more about wildcard masks and search criterion, see this topic.
      using System;
      using ComponentPro.IO;
      using ComponentPro.Net;
      
      ...
      
      // Create a new class instance.
      Ftp client = new Ftp();
      
      // Connect to the FTP server.
      client.Connect("myserver");
      
      // Authenticate.
      client.Authenticate("userName", "password");
      
      // ... 
       
      // Delete all files in folder /my folder.
      client.Delete("/my folder", true, true, null);
      
      // Delete all *.tmp files recursively.
      client.Delete("/temp", true, true, new NameSearchCondition("*.tmp"));
      
      // Delete selected files only. 
      object[] filesToDelete = { "/temp/test.cs", "/test/test.tmp" };
      client.Delete(filesToDelete, true, true, null);
      
      // ... 
       
      // Disconnect.
      client.Disconnect();