Quantcast
Channel: How to get the file name of a file in VB? - Stack Overflow
Viewing all articles
Browse latest Browse all 4

How to get the file name of a file in VB?

$
0
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)    NextEnd 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 TryEnd Sub

Viewing all articles
Browse latest Browse all 4

Latest Images

Trending Articles





Latest Images