Copy Files Using QB45
Copy Files Using QB45
You will probably think me as stupid as a 286, and I have checked the FAQ section, but how can I copy a file from one part of my C:\ drive to another part of my C:\ drive using Quick basic - can it be done?
I can make files and folders - just not copy files...yet
any help or suggestions would be appreciated.
thank you.
I can make files and folders - just not copy files...yet
any help or suggestions would be appreciated.
thank you.
Code: Select all
DECLARE SUB CopyFile (From$, To$)
SUB CopyFile (From$, To$)
' Open the input file in binary mode
InFile = FREEFILE
OPEN From$ FOR BINARY AS #InFile
' Open the output file
' (truncate it if it exists)
OutFile = FREEFILE
OPEN To$ FOR OUTPUT AS #OutFile
CLOSE #OutFile
' Reopen the output file in binary mode
OPEN To$ FOR BINARY AS #OutFile
' Copy the file
DO WHILE NOT EOF(InFile)
Buffer$ = INPUT$(4096, 1)
PUT #OutFile, , Buffer$
LOOP
' Close the files
CLOSE #OutFile
CLOSE #InFile
END SUB
Hi,
Back in 1990, I was confronted with the need to copy files from within a QB program. I played around with different methods that actually read and wrote the records from within the program. I discovered that there there were several sticky little problems that caused the filles not to be exactly the same. I haven't tried Plasma's version, but I have a feeling that this would have some of these problems.
Finally, I decided to do SHELL with the corresponding COPY command, as IanM suggests, and I have never had a problem since. I like this approach because you hand over the responsibility for the COPY, to DOS. A COPY, just like DOS does, is really what you want, so why try to emulate it.
Regards..... Moneo
Back in 1990, I was confronted with the need to copy files from within a QB program. I played around with different methods that actually read and wrote the records from within the program. I discovered that there there were several sticky little problems that caused the filles not to be exactly the same. I haven't tried Plasma's version, but I have a feeling that this would have some of these problems.
Finally, I decided to do SHELL with the corresponding COPY command, as IanM suggests, and I have never had a problem since. I like this approach because you hand over the responsibility for the COPY, to DOS. A COPY, just like DOS does, is really what you want, so why try to emulate it.
Regards..... Moneo
If you are ahead of me, lead.
If you are behind me, follow.
If you are not doing anything,
Get out of the way.
If you are behind me, follow.
If you are not doing anything,
Get out of the way.
- burger2227
- Veteran
- Posts: 2466
- Joined: Mon Aug 21, 2006 12:40 am
- Location: Pittsburgh, PA
Add this to your list Moneo:
If you are ahead of me, lead.
If you are behind me, follow.
If you are not doing anything,
Get out of the way.
If you posted something 3 years ago,
who is the dummy for answering it?![Wink :wink:](./images/smilies/icon_wink.gif)
If you are ahead of me, lead.
If you are behind me, follow.
If you are not doing anything,
Get out of the way.
If you posted something 3 years ago,
who is the dummy for answering it?
![Wink :wink:](./images/smilies/icon_wink.gif)
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
You're right, Ted. That makes me a dummy. I went by the date of the last post, and didn't check the date of the original thread.burger2227 wrote:Add this to your list Moneo:
If you are ahead of me, lead.
If you are behind me, follow.
If you are not doing anything,
Get out of the way.
If you posted something 3 years ago,
who is the dummy for answering it?
Well, live and learn.
Regards..... Moneo
- burger2227
- Veteran
- Posts: 2466
- Joined: Mon Aug 21, 2006 12:40 am
- Location: Pittsburgh, PA
In your defense, the previous poster was a little late replying. LOL
I'm glad you took my post as a joke and not an insult!
Ted
I'm glad you took my post as a joke and not an insult!
Ted
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
- Seb McClouth
- Veteran
- Posts: 342
- Joined: Wed Nov 09, 2005 7:47 am
- Location: Inside the Matrix...
- Contact:
More to defense: we're all dummies... whahoo!!
QBinux is a Linux distribution with the aim of integrating the work of the vast community of free software developers at Pete's QBASIC Site in order to create a modern, performant, safe and easy to use system for system administrators and desktop users.
-
- Veteran
- Posts: 703
- Joined: Sun Nov 14, 2004 7:36 am
- Contact:
Speak for yourself Seb..
I'm not a dummy, I'm just intellectually challenged.![Laughing :lol:](./images/smilies/icon_lol.gif)
I'm not a dummy, I'm just intellectually challenged.
![Laughing :lol:](./images/smilies/icon_lol.gif)
When God created light, so too was born, the first Shadow!
MystikShadows
Need hosting? http://www.jc-hosting.net
Interested in Text & ASCII development? Look no further!
http://www.ascii-world.com
MystikShadows
Need hosting? http://www.jc-hosting.net
Interested in Text & ASCII development? Look no further!
http://www.ascii-world.com
- Seb McClouth
- Veteran
- Posts: 342
- Joined: Wed Nov 09, 2005 7:47 am
- Location: Inside the Matrix...
- Contact:
-
- Veteran
- Posts: 288
- Joined: Sat Feb 18, 2006 4:02 pm
- burger2227
- Veteran
- Posts: 2466
- Joined: Mon Aug 21, 2006 12:40 am
- Location: Pittsburgh, PA
At least nobody called him an A$$hole. What happened to your self-description anyhow?
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0