473,405 Members | 2,344 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,405 software developers and data experts.

Copying File

How to copy file from one path to another path
Apr 28 '07 #1
5 1515
How to copy file from one path to another path
ADD reference to your Project "Microsoft Scripting Runtime"
Use FilesystemObject in Ur Project.
Check The Different Property & method of filesystemobject.

U will get u r Ans.Good Luck.

1st U try find out the sol by yourself.if not possible I will give U the Solve in Details ok?
Apr 28 '07 #2
Another simpler (and perhaps better) way of doing it is simply:

Expand|Select|Wrap|Line Numbers
  1. FileCopy "c:\a.txt", "c:\test\a.txt" // Copies file
  2. Kill "c:\a.txt" // Deletes original file
This is the simplest way, but leaves out a lot of error-catching.
Apr 28 '07 #3
Another simpler (and perhaps better) way of doing it is simply:

Expand|Select|Wrap|Line Numbers
  1. FileCopy "c:\a.txt", "c:\test\a.txt" // Copies file
  2. Kill "c:\a.txt" // Deletes original file
This is the simplest way, but leaves out a lot of error-catching.
I think there r two Problems in this code.

1)U can't say whether the File Exist in specific Path or not.
if the file doesn't exist in specific Path then U will get a runtime error. for Both
Statement.
2)the requirement is to copy the file, not to move the file so the Kill statement is
not required
Apr 29 '07 #4
Killer42
8,435 Expert 8TB
I think there r two Problems in this code.

1)U can't say whether the File Exist in specific Path or not.
if the file doesn't exist in specific Path then U will get a runtime error. for Both
Statement.
2)the requirement is to copy the file, not to move the file so the Kill statement is
not required
It is fairly simple to check whether the source/dest files exist before attempting the copy. It's well worth learning about FileSystemObject, as it provides much more functionality than the built-in commands. But it's not always necessary.

Also, I think it was nice of cbbibleboy to throw in the extra code demonstrating how to zap the original file if required. However, it might have been nice to make a more prominent note about what/why, to avoid disasters.

Oh, one other thing I'm curious about. What's the idea with the "//"? It doesn't compile under VB6. Is it...
  • from a different (probably later) version of VB?
  • from a different language, and shouldn't really be there?
  • intended to prevent accidental execution?
  • other?
Apr 30 '07 #5
Yeah, that was just the simplest fix. And the '//' was an accident. I write in C most of the time so it was just a habit.
Apr 30 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Thomas Lotze | last post by:
Hi, another question: What's the most efficient way of copying data between two file-like objects? f1.write(f2.read()) doesn't seem to me as efficient as it might be, as a string containing...
3
by: Robert Tarantino | last post by:
Hello, I am trying to find a way to create a scheduled task or service that will copy my local profile folders under "Documents and settings" to a network drive. This would allow me to restore...
4
by: Alex Vinokur | last post by:
Copying files : input to output =============================== C/C++ Performance Tests ======================= Using C/C++ Program Perfometer http://sourceforge.net/projects/cpp-perfometer...
10
by: Martin Ho | last post by:
I am running into one really big problem. I wrote a script in vb.net to make a copy of folders and subfolder to another destination: - in 'from.txt' I specify which folders to copy - in...
2
by: somequestion | last post by:
During copying file , wanna read file Size like this string CheckFileSize(string fileName) { if( fileName == null ) return; FileInfo fi = new FileInfo(fileName); return fi.Length.ToString();...
18
by: mike3 | last post by:
Hi. I have an interesting problem. The C program presented below takes around 12 seconds to copy 128 MB of data on my machine. Yet I know the machine can go faster since a copying done at a...
6
by: kimiraikkonen | last post by:
Hi, I use system.io.file class to copy files but i have a difficulty about implementing a basic / XP-like progress bar indicator during copying process. My code is this with no progress bar,...
4
by: Jim Barlow | last post by:
Does anyone know why K&R2 uses the term "File Copying" at this point (1.5.1)? Also, in the K&R2 answers to exercises maintained by Richard Heathfield, for Listing KRX113 Mr Heathfield repeatedly...
13
by: writeson | last post by:
Hi all, I'm writing some code that monitors a directory for the appearance of files from a workflow. When those files appear I write a command file to a device that tells the device how to...
2
by: raylopez99 | last post by:
Beware newbies: I spent a day before I figured this out: copying a bitmap (image) file to file is not quite like copying a text file--you have to do some tricks (see below), like using a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.