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

How to use the shell function in vb6.0 to copy file from one directory to another

P: 16
Halu! Is there anyone who could give me an advice about this code?
I have a file named db1.mdb in with a full path of "c:\firstfolder\copy db1.mdb" which i want to transfer to another directory "e:\secondfolder". This is supposed to be creating a backup routine for an application i am developing.
This is the code that i used.

I am using Visual Basic 6.0 Enterprise edition. My database was created in access. I am using a Windows XP Operating system.

shell("cmd.exe /c " & "c:\firstfolder\copy db1.mdb e:\secondfolder")
Mar 28 '07 #1
Share this Question
Share on Google+
5 Replies


pureenhanoi
100+
P: 175
Halu! Is there anyone who could give me an advice about this code?
I have a file named db1.mdb in with a full path of "c:\firstfolder\copy db1.mdb" which i want to transfer to another directory "e:\secondfolder". This is supposed to be creating a backup routine for an application i am developing.
This is the code that i used.

I am using Visual Basic 6.0 Enterprise edition. My database was created in access. I am using a Windows XP Operating system.

shell("cmd.exe /c " & "c:\firstfolder\copy db1.mdb e:\secondfolder")
i think you do not need using shell command. VB6 has procedure to copy file from source folder to destination folder. Try it:
Expand|Select|Wrap|Line Numbers
  1.  
  2. On Error Resume Next
  3. filecopy "c:\firstfolder\db1.mdb","e:\secondfolder\db1.mdb"
  4. if Err then
  5.        msgbox "copy error"
  6. end if
  7.  
Mar 28 '07 #2

P: 16
i think you do not need using shell command. VB6 has procedure to copy file from source folder to destination folder. Try it:
Expand|Select|Wrap|Line Numbers
  1.  
  2. On Error Resume Next
  3. filecopy "c:\firstfolder\db1.mdb","e:\secondfolder\db1.mdb"
  4. if Err then
  5.        msgbox "copy error"
  6. end if
  7.  

Thank you very much... The code works... I had tried it before but i omitted the filetitle in the secondfolder that's why i got a path/file access error.

Anyway it now works... thank you so much...

By the way, if you have any idea about the other way i want, the one using shell to copy the file, please give me also. Because i want to be able to learn on supplying dos commands to shell function in vb6.0
Mar 28 '07 #3

100+
P: 149
i think you do not need using shell command. VB6 has procedure to copy file from source folder to destination folder. Try it:
Expand|Select|Wrap|Line Numbers
  1.  
  2. On Error Resume Next
  3. filecopy "c:\firstfolder\db1.mdb","e:\secondfolder\db1.mdb"
  4. if Err then
  5.        msgbox "copy error"
  6. end if
  7.  

Yes you can use this command
FileCopy "c:\firstfolder\db1.mdb","e:\secondfolder\db1. mdb"

and this should copy the file from the sorce directory to the Target directory.

thanks
ansuman
Mar 28 '07 #4

100+
P: 149
Thank you very much... The code works... I had tried it before but i omitted the filetitle in the secondfolder that's why i got a path/file access error.

Anyway it now works... thank you so much...

By the way, if you have any idea about the other way i want, the one using shell to copy the file, please give me also. Because i want to be able to learn on supplying dos commands to shell function in vb6.0
Hi ,

Look at this link

http://www.freevbcode.com/ShowCode.Asp?ID=499

this will give you an idea on how to use Shell API for copying files.

thanks
ansuman sahu
Mar 28 '07 #5

P: 16
Yes you can use this command
FileCopy "c:\firstfolder\db1.mdb","e:\secondfolder\db1. mdb"

and this should copy the file from the sorce directory to the Target directory.

thanks
ansuman

Halu there! :-) thanks for sharing your ideas.

I got the shell ( ) also...

try this

shell("cmd.exe /c " & "copy c:\firstfolder\db1.mdb e:\secondfolder")
Mar 28 '07 #6

Post your reply

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