Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

how to copy a file from a given location to another

Posted on 2003-04-01
6
Medium Priority
?
128 Views
Last Modified: 2010-05-01
hi,
Can u tell mehow to copy a file from a given location to another in vb.I tried FileCopy method it gave an error.
Ananthan
0
Comment
Question by:rtananthan
6 Comments
 
LVL 14

Accepted Solution

by:
aelatik earned 120 total points
ID: 8244098
Did you try it correctly, because it has to work...

FileCopy "c:\filename.ext", "a:\filename.ext"
0
 
LVL 55

Expert Comment

by:Ryan Chong
ID: 8244119
Try this:

Private Declare Function URLDownloadToFile Lib "urlmon" _
                     Alias "URLDownloadToFileA" _
                    (ByVal pCaller As Long, _
                     ByVal szURL As String, _
                     ByVal szFilename As String, _
                     ByVal dwReserved As Long, _
                     ByVal lpfnCB As Long) As Long
Private Declare Function DeleteUrlCacheEntry Lib "wininet.dll" Alias "DeleteUrlCacheEntryA" (ByVal lpszUrlName As String) As Long
Private Const ERROR_SUCCESS As Long = 0


Private Function DownloadFile(ByVal sURL As String, _
                             ByVal sLocalFile As String) As Boolean

   Dim lngRetVal As Long
   
  'if the API returns ERROR_SUCCESS (0),
  'return True from the function
   DownloadFile = URLDownloadToFile(0&, _
                                    sURL, _
                                    sLocalFile, _
                                    0&, _
                                    0&) = ERROR_SUCCESS
   
End Function

Private Function DeleteCache(sURL As String) As Boolean
    DeleteCache = DeleteUrlCacheEntry(sURL)
End Function

Use like:

DownloadFile sourcepath, targetpath

Add DeleteCache sourcepath before the line if you want to download an internet file.

Hope this helps
0
 
LVL 77

Expert Comment

by:GrahamSkan
ID: 8244169
What is your exact statement and what was the error?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 3

Expert Comment

by:emadat
ID: 8246390
Try this:
Shell "cmd /C copy file1_path_name file2_path_name"

This will simply let the OS do the copy for you
0
 

Expert Comment

by:CleanupPing
ID: 8531215
Hi rtananthan,
This old question (QID 20569782) needs to be finalized -- accept an answer, split points, or get a refund.  Please see http://www.cityofangels.com/Experts/Closing.htm for information and options.
0
 
LVL 77

Expert Comment

by:GrahamSkan
ID: 9017774
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
Accept aelatik's comment as answer
Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
GrahamSkan
EE Cleanup Volunteer
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month12 days, 3 hours left to enroll

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question