Gets or sets the recursion mode indicating whether to allow scanning subdirectories for files. The default value is true.

      Syntax

      public bool Recursive { get; set; }

      Examples

      FTP Examples

      Shows how to use the Recursion Mode in transferring files.

      using System;
      using ComponentPro;
      using ComponentPro.Net;
      using ComponentPro.IO;
      
      ...
      
      private Ftp _client;
      public void DoUpload()
      {
          // Create a new class instance. 
          Ftp client = new Ftp();
          _client = client;
      
          // Connect to the FTP server. 
          client.Connect("demo.componentpro.com");
      
          // Authenticate. 
          client.Authenticate("test", "test");
      
          // ... 
       
          client.Progress += client_Progress;
      
          // Do not scan subdirectories for files to transfer. It means only files in the specified directory are to be transferred. 
          TransferOptions opt = new TransferOptions(
                  true, // BuildDirectoryTreeBeforeTransfer = true. 
                  false,
                  OptionValue.Auto, 
                  new NameSearchCondition("*.exe"), // upload .exe files 
                  FileOverwriteMode.Overwrite,
                  SymlinksResolveAction.Skip);
      
          // Upload all .exe files in local folder 'c:\myfolder' to remote folder '/myfolder'. 
          client.Upload("c:\\myfolder", "/myfolder", opt);
      
          // ... 
       
          // Scan all subdirectories for files to transfer. 
          opt = new TransferOptions(
                  true, // BuildDirectoryTreeBeforeTransfer = true. 
                  true,
                  OptionValue.Auto, 
                  new NameSearchCondition("*.dll"), // upload .dll files 
                  FileOverwriteMode.Overwrite,
                  SymlinksResolveAction.Skip);
      
          // Upload all .dll files in local folder 'c:\myfolder' to remote folder '/myfolder'. 
          client.Upload("c:\\myfolder", "/myfolder", opt);
      
          // ... 
       
          // Scan subdirectories that match the search condition for files to transfer. 
          opt = new TransferOptions(
                  true, // BuildDirectoryTreeBeforeTransfer = true. 
                  true,
                  OptionValue.Auto,
                  new NameSearchCondition("*.cs;*.vb", SearchConditionFileTypes.File) | new NameSearchCondition("mydir*", SearchConditionFileTypes.Directory), // upload .cs and .vb files in the specified directory and subdirectories with names starting with 'mydir' 
                  FileOverwriteMode.Overwrite,
                  SymlinksResolveAction.Skip);
      
          // Upload .cs and .vb files in the specified directory and subdirectories with names starting with 'mydir' 
          client.Upload("c:\\myfolder", "/myfolder", opt);
      
          // Upload files except some extensions. 
          SearchCondition excludeCondition = new NotSearchCondition(new NameSearchCondition("*.ncb|*.pdb|*.vshost.exe|*.vshost.exe.config|*.user|*.vspscc|*.vssscc|*.scc"));
          // Upload directories except 'obj' 'bin' 'Debug' and 'Release' folders. 
          SearchCondition excludeBinCondition = new NotSearchCondition(new NameSearchCondition("obj|bin|Output|Debug|Release|ReleaseTrial", SearchConditionFileTypes.Directory));
      
          opt = new TransferOptions(
                  true, // BuildDirectoryTreeBeforeTransfer = true. 
                  true,
                  OptionValue.Auto,
                  excludeCondition + excludeBinCondition,
                  FileOverwriteMode.Overwrite,
                  SymlinksResolveAction.Skip);
      
          // Upload files and directories that match the search condition. 
          client.Upload("c:\\Test", "/test", opt);
      
          // ... 
       
          // Disconnect. 
          client.Disconnect();
      }
      
      /// <summary> 
      /// This method is raised when user clicks on 'Cancel' button on the form. 
      /// </summary> 
      protected void btnCancel_Click(object sender, EventArgs e)
      {
          // Cancel the upload operation when user clicks on the button. 
          _client.Cancel();
      }
      
      void client_Progress(object sender, ComponentPro.IO.FileSystemProgressEventArgs e)
      {
          // Show progress info. 
          Console.WriteLine("Current File: %{0} completed", e.Percentage);
          Console.WriteLine("Total: %{0} completed", e.TotalPercentage);
      
          switch (e.State)
          {
              case TransferState.BuildingDirectoryStructure:
                  Console.WriteLine("Building directory structure...");
                  break;
      
              case TransferState.StartUploadingFile:
                  if (e.SourcePath.EndsWith(".exe"))
                  {
                      // Skip all .exe files 
                      e.Skip = true;
                  }
                  else if (e.SourcePath.StartsWith(@"C:\MyFolder"))
                  {
                      // Change the source file path if it starts with "C:\MyFolder" 
                      e.SourcePath = e.SourcePath.Replace(@"C:\MyFolder", @"C:\MySecondFolder");
                  }
                  break;
          }
      }

      SFTP Examples

      Shows how to use the Recursion Mode in transferring files.

      using System;
      using System.Collections.Generic;
      using System.Text;
      using ComponentPro;
      using ComponentPro.Net;
      using ComponentPro.IO;
      using System.Windows.Forms;
      
      ...
      
      private Sftp _client;
      public void DoUpload()
      {
          // Create a new class instance. 
          Sftp client = new Sftp();
          _client = client;
      
          // Connect to the SFTP server. 
          client.Connect("demo.componentpro.com");
      
          // Authenticate. 
          client.Authenticate("test", "test");
      
          // ... 
       
          client.Progress += client_Progress;
      
          // Do not scan subdirectories for files to transfer. It means only files in the specified directory are to be transferred. 
          TransferOptions opt = new TransferOptions(
                  true, // BuildDirectoryTreeBeforeTransfer = true. 
                  false,
                  OptionValue.Auto, 
                  new NameSearchCondition("*.exe"), // upload .exe files 
                  FileOverwriteMode.Overwrite,
                  SymlinksResolveAction.Skip);
      
          // Upload all .exe files in local folder 'c:\myfolder' to remote folder '/myfolder'. 
          client.Upload("c:\\myfolder", "/myfolder", opt);
      
          // ... 
       
          // Scan all subdirectories for files to transfer. 
          opt = new TransferOptions(
                  true, // BuildDirectoryTreeBeforeTransfer = true. 
                  true,
                  OptionValue.Auto, 
                  new NameSearchCondition("*.dll"), // upload .dll files 
                  FileOverwriteMode.Overwrite,
                  SymlinksResolveAction.Skip);
      
          // Upload all .dll files in local folder 'c:\myfolder' to remote folder '/myfolder'. 
          client.Upload("c:\\myfolder", "/myfolder", opt);
      
          // ... 
       
          // Scan subdirectories that match the search condition for files to transfer. 
          opt = new TransferOptions(
                  true, // BuildDirectoryTreeBeforeTransfer = true. 
                  true,
                  OptionValue.Auto, 
                  new NameSearchCondition("*.cs;*.vb", SearchConditionFileTypes.File) | new NameSearchCondition("mydir*", SearchConditionFileTypes.Directory), // upload .cs and .vb files in the specified directory and subdirectories with names starting with 'mydir' 
                  FileOverwriteMode.Overwrite,
                  SymlinksResolveAction.Skip);
      
          // Upload .cs and .vb files in the specified directory and subdirectories with names starting with 'mydir' 
          client.Upload("c:\\myfolder", "/myfolder", opt);
      
          // ... 
       
          // Upload files except some extensions. 
          SearchCondition excludeCondition = new NotSearchCondition(new NameSearchCondition("*.ncb|*.pdb|*.vshost.exe|*.vshost.exe.config|*.user|*.vspscc|*.vssscc|*.scc"));
          // Upload directories except 'obj' 'bin' 'Debug' and 'Release' folders. 
          SearchCondition excludeBinCondition = new NotSearchCondition(new NameSearchCondition("obj|bin|Output|Debug|Release|ReleaseTrial", SearchConditionFileTypes.Directory));
      
          opt = new TransferOptions(
                  true, // BuildDirectoryTreeBeforeTransfer = true. 
                  true,
                  OptionValue.Auto, 
                  excludeCondition + excludeBinCondition,
                  FileOverwriteMode.Overwrite,
                  SymlinksResolveAction.Skip);
      
          // Upload files and directories that match the search condition. 
          client.Upload("c:\\Test", "/test", opt);
      
          // Disconnect. 
          client.Disconnect();
      }
      
      /// <summary> 
      /// This method is raised when user clicks on 'Cancel' button on the form. 
      /// </summary> 
      protected void btnCancel_Click(object sender, EventArgs e)
      {
          // Cancel the upload operation when user clicks on the button. 
          _client.Cancel();
      }
      
      void client_Progress(object sender, ComponentPro.IO.FileSystemProgressEventArgs e)
      {
          // Show progress info. 
          Console.WriteLine("Current File: %{0} completed", e.Percentage);
          Console.WriteLine("Total: %{0} completed", e.TotalPercentage);
      
          switch (e.State)
          {
              case TransferState.BuildingDirectoryStructure:
                  Console.WriteLine("Building directory structure...");
                  break;
      
              case TransferState.StartUploadingFile:
                  if (e.SourcePath.EndsWith(".exe"))
                  {
                      // Skip all .exe files 
                      e.Skip = true;
                  }
                  else if (e.SourcePath.StartsWith(@"C:\MyFolder"))
                  {
                      // Change the source file path if it starts with "C:\MyFolder" 
                      e.SourcePath = e.SourcePath.Replace(@"C:\MyFolder", @"C:\MySecondFolder");
                  }
                  break;
          }
      
          // Keep the form active 
          Application.DoEvents();
      }

      ZIP Examples

      Shows how to use the Recursion Mode in transferring files.

      using System;
      using System.Collections.Generic;
      using System.Text;
      using ComponentPro;
      using ComponentPro.Compression;
      using ComponentPro.IO;
      using System.Windows.Forms;
      
      ...
      
      private Zip _zip;
      public void DoUpload()
      {
          // Create a new instance. 
          Zip zip = new Zip();
          _zip = zip;
      
          // Open an existing archive. 
          zip.Open("test.zip");
      
          // ... 
       
          zip.Progress += zip_Progress;
      
          // Do not scan subdirectories for files to transfer. It means only files in the specified directory are to be transferred. 
          TransferOptions opt = new TransferOptions(
                  true, // BuildDirectoryTreeBeforeTransfer = true. 
                  false,
                  OptionValue.Auto, 
                  new NameSearchCondition("*.exe"), // upload .exe files 
                  FileOverwriteMode.Overwrite,
                  SymlinksResolveAction.Skip);
      
          // Add all .exe files in local folder 'c:\myfolder' to remote folder '/myfolder'. 
          zip.AddFiles("c:\\myfolder", "/myfolder", opt);
      
          // ... 
       
          // Scan all subdirectories for files to transfer. 
          opt = new TransferOptions(
                  true, // BuildDirectoryTreeBeforeTransfer = true. 
                  true,
                  OptionValue.Auto,
                  new NameSearchCondition("*.dll"), // upload .dll files 
                  FileOverwriteMode.Overwrite,
                  SymlinksResolveAction.Skip);
      
          // Add all .dll files in local folder 'c:\myfolder' to remote folder '/myfolder'. 
          zip.AddFiles("c:\\myfolder", "/myfolder", opt);
      
          // ... 
       
          // Scan subdirectories that match the search condition for files to transfer. 
          opt = new TransferOptions(
                  true, // BuildDirectoryTreeBeforeTransfer = true. 
                  true,
                  OptionValue.Auto,
                  new NameSearchCondition("*.cs;*.vb", SearchConditionFileTypes.File) | new NameSearchCondition("mydir*", SearchConditionFileTypes.Directory), // upload .cs and .vb files in the specified directory and subdirectories with names starting with 'mydir' 
                  FileOverwriteMode.Overwrite,
                  SymlinksResolveAction.Skip);
      
          // Add .cs and .vb files in the specified directory and subdirectories with names starting with 'mydir' 
          zip.AddFiles("c:\\myfolder", "/myfolder", opt);
      
          // ... 
       
          // Upload files except some extensions. 
          SearchCondition excludeCondition = new NotSearchCondition(new NameSearchCondition("*.ncb|*.pdb|*.vshost.exe|*.vshost.exe.config|*.user|*.vspscc|*.vssscc|*.scc"));
          // Upload directories except 'obj' 'bin' 'Debug' and 'Release' folders. 
          SearchCondition excludeBinCondition = new NotSearchCondition(new NameSearchCondition("obj|bin|Output|Debug|Release|ReleaseTrial", SearchConditionFileTypes.Directory));
      
          opt = new TransferOptions(
                  true, // BuildDirectoryTreeBeforeTransfer = true. 
                  true,
                  OptionValue.Auto,
                  excludeCondition + excludeBinCondition,
                  FileOverwriteMode.Overwrite,
                  SymlinksResolveAction.Skip);
      
          // Add files and directories that match the search condition. 
          zip.AddFiles("c:\\Test", "/test", opt);
      
          // Close. 
          zip.Close();
      }
      
      /// <summary> 
      /// This method is raised when user clicks on 'Cancel' button on the form. 
      /// </summary> 
      protected void btnCancel_Click(object sender, EventArgs e)
      {
          // Cancel the upload operation when user clicks on the button. 
          _zip.Cancel();
      }
      
      void zip_Progress(object sender, ComponentPro.IO.FileSystemProgressEventArgs e)
      {
          // Show progress info. 
          Console.WriteLine("Current File: %{0} completed", e.Percentage);
          Console.WriteLine("Total: %{0} completed", e.TotalPercentage);
      
          switch (e.State)
          {
              case TransferState.BuildingDirectoryStructure:
                  Console.WriteLine("Building directory structure...");
                  break;
      
              case TransferState.StartUploadingFile:
                  if (e.SourcePath.EndsWith(".exe"))
                  {
                      // Skip all .exe files 
                      e.Skip = true;
                  }
                  else if (e.SourcePath.StartsWith(@"C:\MyFolder"))
                  {
                      // Change the source file path if it starts with "C:\MyFolder" 
                      e.SourcePath = e.SourcePath.Replace(@"C:\MyFolder", @"C:\MySecondFolder");
                  }
                  break;
          }
      
          // Keep the form active 
          Application.DoEvents();
      }

      Framework

      .NET Compact Framework.NET Compact Framework

      Supported version: 2.0, 3.5, and 3.9
      Assembly: ComponentPro.FileSystem.CF (in ComponentPro.FileSystem.CF.dll)

      .NET Framework.NET Framework

      Supported version: 2.0, 3.0, 3.5, 4.0, 4.5.x, 4.6.x and later
      Assembly: ComponentPro.FileSystem (in ComponentPro.FileSystem.dll)

      Portable Class Library for Windows Phone 8.1 and Windows 8.1 Store AppsPortable Class Library for Windows Phone 8.1 and Windows 8.1 Store Apps

      Supported version: 4.6.x and later
      Assembly: ComponentPro.FileSystem.WinPcl (in ComponentPro.FileSystem.WinPcl.dll)

      Universal Windows Platform (includes Windows 10 Mobile, Windows 10 Store Apps and Windows 10 IoT)Universal Windows Platform (includes Windows 10 Mobile, Windows 10 Store Apps and Windows 10 IoT)

      Supported version: 4.6.x and later
      Assembly: ComponentPro.FileSystem.Uwp (in ComponentPro.FileSystem.Uwp.dll)

      Xamarin AndroidXamarin Android

      Supported version: 2.3 and later
      Assembly: ComponentPro.FileSystem.Android (in ComponentPro.FileSystem.Android.dll)

      Xamarin MacXamarin Mac

      Supported version: 2.0.x and later
      Assembly: ComponentPro.FileSystem.Mac (in ComponentPro.FileSystem.Mac.dll)

      Xamarin iOSXamarin iOS

      Supported version: 5.1.x and later
      Assembly: ComponentPro.FileSystem.iOS (in ComponentPro.FileSystem.iOS.dll)

      See Also