473,386 Members | 1,766 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,386 software developers and data experts.

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

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
5 32757
pureenhanoi
175 100+
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
Lavs
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
ansumansahu
149 100+
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
ansumansahu
149 100+
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
Lavs
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

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

Similar topics

3
by: John Bowling | last post by:
I'm creating a routine (not in a browser) to move multiple files on a daily basis to a backup directory. It can be done easily by call shell functions like 'mv file* newdir'. I can't find any...
9
by: Jeff Wagner | last post by:
I have a project of converting numerous DOS cmd shell scripts to Python. Is there a tutorial to getting started? Thanks, Jeff
4
by: Salty Dog | last post by:
No error or any feedback that I can work with. Code: set objShell = Server.CreateObject("WScript.Shell") objShell.Run "%comspec% /c NET PRINT \\Garchive\ISLaser >c:\WUTemp\Printer_Status1.txt",...
5
by: L337Hax0r | last post by:
for my operating systems design class i am supposed to write a shell in c. i have no idea where to start and our teacher hasn't given us much info. anyone know of any good tutorials?
8
by: zhiwei wang | last post by:
I remember that there is a function that could invoke shell command such as "rm" "cp", directly in .c file. But I could not recall its name, and I googled with nothing meaningful. I vaguely...
3
by: dibblm | last post by:
Below is current code used. I can only list one directory then move to next. I want to search one more directory further and can't seem to find how to get one deeper. What I want to accomplish is...
1
by: kumarboston | last post by:
Hi all, I am trying to copy couple of directories and their files to another place. Each directory have 25-30 files and numbered accordingly, the problem I am facing is, I have to copy files...
3
by: Max Vit | last post by:
I have come across a strange issue whilst trying to use a shell command call from Access and have spent some time trying to figure this out but can't find the cause as yet. The issue is: I need...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...

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.