move a file with a wildcard

  • Thread starter Thread starter Kevin Rose
  • Start date Start date
K

Kevin Rose

I need to move a file from one location (Source) to
another (Destination). I currently use:

System.IO.File.Move(source, destination)

My problem is that the source file name changes. It is
called FileXXXX.txt where XXXX is the timestamp of when
the file was created. I want to read in this file using a
wildcard and move it to a different location. Thus I want
to be able to find File*.txt. How can I do this? It
fails if I have * in my source string. There there a
special syntax I must use?
 
I need to move a file from one location (Source) to
another (Destination). I currently use:

System.IO.File.Move(source, destination)

My problem is that the source file name changes. It is
called FileXXXX.txt where XXXX is the timestamp of when
the file was created. I want to read in this file using a
wildcard and move it to a different location. Thus I want
to be able to find File*.txt. How can I do this? It
fails if I have * in my source string. There there a
special syntax I must use?

I think you'll need to use Directory.GetFiles() to get all the files
that match your search criteria (File*.txt). Then loop through the
result and move each file seperately.
 
Back
Top