title: How to transfer files form folders and sub-folders to specific folders created by file name pattern in C# (File2specific Folders)
body: <p>As you can see in code, folders are created during move file button. my question is that how to moves files in that particular folders, I have tens of millions of files and want to moves in that particulars. I am new in c#.</p>
  <p><a href="https://i.stack.imgur.com/3WxZX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3WxZX.png" alt="enter image description here" /></a></p>
  <pre><code>using System.Text;
  using System.Threading.Tasks;
  using System.Windows.Forms;
  using System.IO;
  
  namespace File2Folders
  {
      public partial class Form1 : Form
      {
          public Form1()
          {
              InitializeComponent();
          }
          List&lt;string&gt; fileName = null;
          List&lt;string&gt; fileNames = null;
          private void btn_browse_Click(object sender, EventArgs e)
          {
              using (FolderBrowserDialog fbd = new FolderBrowserDialog())
              {
                  if (fbd.ShowDialog() == DialogResult.OK)
                  {
                      listBox1.Items.Clear();
                      fileName = Directory.GetFiles(fbd.SelectedPath).ToList();
                      fileNames = fileName.Select(item =&gt; Path.GetFileNameWithoutExtension(item).Substring(1, 4)).OrderBy(n=&gt;n).ToList();
                      listBox1.DataSource = fileName.Select(f =&gt; Path.GetFileName(f)).ToList();
                      listBox2.DataSource = fileNames;         
                  }
              }
          }
          private void btn_move_Click(object sender, EventArgs e)
          {
              using (FolderBrowserDialog fbd = new FolderBrowserDialog())
              {
                  if (fbd.ShowDialog() == DialogResult.OK)
                  {
                      fileNames.ForEach(item =&gt; Directory.CreateDirectory(Path.Combine(fbd.SelectedPath, item)));
                  
                  }
  </code></pre>