473,324 Members | 2,248 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

File.Copy Method

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
2 1444
"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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Dave Smithz | last post by:
Hi There, I have a PHP script that sends an email with attachment and works great when provided the path to the file to send. However this file needs to be on the same server as the script. ...
2
by: RitaG | last post by:
Hi. In a VB.Net program I use File.Copy to copy some zipped (and text) files from one server to another. I'm required by management to do a file compare after the copy has completed. Is the...
8
by: Siu | last post by:
Hi, is it possible to sort a XML file without using a XSLT or XSL file?? For example, my XML is: <A> <1> <3> <4> <2> </A>
0
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen....
4
by: Brian Hanson | last post by:
Hi, I have a problem that is sporadic and am thinking it may come down to a timing issue. I have an asp.net (vb) app that used the system.io.file.copy method to copy a .pdf file from a network...
8
by: Dinesh Jain | last post by:
Hi all, I encountered a serious problem while working with clipboard class in VB.NET. I want to simulate cut-copy-paste operation with my application and Windows Explorer. User can copy files...
9
by: CGW | last post by:
I asked the question yesterday, but know better how to ask it, today: I'm trying to use the File.Copy method to copy a file from a client to server (.Net web app under IIS ). It looks to me that...
17
by: Peter Duniho | last post by:
I searched using Google, on the web and in the newsgroups, and found nothing on this topic. Hopefully that means I just don't understand what I'm supposed to be doing here. :) The problem: ...
1
by: sandhyabhavani | last post by:
This article is used to zip a file or directory using vb.net. The classes and method to zip a file is availale in java.io, java.util, java.util.zip class library.To import these you have to add a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.