By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,581 Members | 1,811 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,581 IT Pros & Developers. It's quick & easy.

File.Copy Method

P: n/a
Jul
File.Copy Method does not let use template for copying files,
I can not use File.Copy("C:\ABC\*.txt", "C:\XYZ\*.txt")

but I need to use such way:
File.Copy("C:\ABC\1.txt", "C:\XYZ\1.txt")
File.Copy("C:\ABC\2.txt", "C:\XYZ\2.txt")

Does exist way in .Net for copying file by template?
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"Jul" <ju********@sympatico.ca> wrote in news:MSJ6d.12266$MD5.920857
@news20.bellglobal.com:
File.Copy Method does not let use template for copying files,
I can not use File.Copy("C:\ABC\*.txt", "C:\XYZ\*.txt")

Use the File.Directory.GetFiles method to filter your directory.

Then call File.Copy for each item in GetFiles.

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 21 '05 #2

P: n/a
You'll have to loop through the directory and copy the files one by one:

Dim SourceDir As String = "C\ABC"
Dim DestDir As String = "C:\XYZ"
Dim DestFile As String

For Each strFile As String In Directory.GetFiles(SourceDir, "*.txt")
DestFile = strFile.Replace(SourceDir, DestDir)
File.Copy(strFile, DestFile)
Next strFile
hope that helps..
Imran.

"Jul" <ju********@sympatico.ca> wrote in message
news:MS********************@news20.bellglobal.com. ..
File.Copy Method does not let use template for copying files,
I can not use File.Copy("C:\ABC\*.txt", "C:\XYZ\*.txt")

but I need to use such way:
File.Copy("C:\ABC\1.txt", "C:\XYZ\1.txt")
File.Copy("C:\ABC\2.txt", "C:\XYZ\2.txt")

Does exist way in .Net for copying file by template?

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.