move a file with a wildcard

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?
 
P

Patrick Steele [MVP]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top