title: How to get the file name of a file in VB?
body: <p>I make a search program for searching a list of files in a computer and then copy the file into a store folder. The file name could be "*11*2.txt" As long as the program find this pattern, it should copy to the store folder. The problem is that I don't know the exactly name of the file before the search and I don't want to rename the file, I don't know how to save the file. Please help</p>
  
  <p>I use the following to find the file, which does its work</p>
  
  <pre><code>Public Sub DirSearch(ByVal sDir As String, ByVal FileName As String)
      Dim To_Path As String
      To_Path = Form1.TextBox5.Text
      For Each foundFile As String In My.Computer.FileSystem.GetFiles(sDir, FileIO.SearchOption.SearchAllSubDirectories, FileName)
          Copy2Local(foundFile, To_Path)
      Next
  End Sub
  </code></pre>
  
  <p>Here is the current version  of the Copy2Local (Note: it is not working right)</p>
  
  <pre><code>    Public Sub Copy2Local(ByVal Copy_From_Path As String, ByVal Copy_To_Path As String)
      ' Specify the directories you want to manipulate.
  
      Try
          Dim fs As FileStream = File.Create(Copy_From_Path)
          fs.Close()
  
  
          ' Copy the file.
          File.Copy(Copy_From_Path, Copy_To_Path)
      Catch
  
      End Try
  End Sub
  </code></pre>