Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8480387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:16:53+00:00 2026-06-10T19:16:53+00:00

I make a search program for searching a list of files in a computer

  • 0

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

I use the following to find the file, which does its work

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

Here is the current version of the Copy2Local (Note: it is not working right)

    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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T19:16:54+00:00Added an answer on June 10, 2026 at 7:16 pm

    First, you should check if ToPath is a valid directory since it’s coming from a TextBox:

    Dim isValidDir = Directory.Exists(ToPath)
    

    Second, you can use Path.Combine to create a path from separate (sub)directories or file-names:

    Dim copyToDir = Path.GetDirectoryName(Copy_To_Path)
    Dim file = Path.GetFileName(Copy_From_Path)
    Dim newPath = Path.Combine(copyToDir, file)
    

    http://msdn.microsoft.com/en-us/library/system.io.path.aspx

    (disclaimer: typed from a mobile)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I want to make a program that allows you to store and search
I am trying to make a program that will search for a file on
I want to make my program print huge list of all files that I
I have to make an uninformed search (Breadth-first-Search) program which takes two nodes and
I make a program that shows a table. If people click the search I
I want to make a search method from a list of Restaurants. The user
I am attempting to make a program that will input numbers into an array
I have a FindFile routine in my program which will list files, but if
Do you have any tutorial how to make a search program in vb.net? I
The general point of the program is to search for words and make sure

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.