Page 1 of 1
Copy Files Using QB45
Posted: Thu Nov 09, 2006 5:40 am
by IanM
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.
Posted: Thu Nov 09, 2006 8:09 am
by IanM
Its ok... I think its sorted
I assembled a String$ which was in the format "copy folder1/file1 folder2/file2"
then used SHELL String$
and things seem ok
if there is a better way please let me know.
Posted: Thu Nov 09, 2006 11:12 am
by sid6.7
are they just plain text files?
Posted: Thu Nov 09, 2006 1:17 pm
by Plasma
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
Thank You
Posted: Tue Jul 28, 2009 5:20 am
by IanM
deepest appologies - for not replying earlier, but thank you for your time. (and yes they were just text files)
Posted: Wed Jul 29, 2009 12:02 pm
by moneo
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
Posted: Wed Jul 29, 2009 2:48 pm
by burger2227
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)
Posted: Thu Jul 30, 2009 12:33 pm
by moneo
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?
![Wink :wink:](./images/smilies/icon_wink.gif)
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.
Well, live and learn.
Regards..... Moneo
Posted: Thu Jul 30, 2009 1:32 pm
by burger2227
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
Posted: Thu Jul 30, 2009 1:55 pm
by Seb McClouth
More to defense: we're all dummies... whahoo!!
Posted: Fri Jul 31, 2009 7:02 am
by MystikShadows
Speak for yourself Seb..
I'm not a dummy, I'm just intellectually challenged.
![Laughing :lol:](./images/smilies/icon_lol.gif)
Posted: Fri Jul 31, 2009 1:24 pm
by Seb McClouth
well most of us are, therefor we're dummies
![Laughing :lol:](./images/smilies/icon_lol.gif)
Posted: Fri Aug 07, 2009 10:19 am
by IanM
? what have I created.... ?
![Smile :)](./images/smilies/icon_smile.gif)
Posted: Fri Aug 07, 2009 7:01 pm
by bungytheworm
The one who ignores and denies the fact he's a dummy, is the real dumb. I accept the fact im dummy, that makes me pretty darn wise.
? what have I created.... ?
You did not create anything, but for sure you did wake up something
![Laughing :lol:](./images/smilies/icon_lol.gif)
Posted: Fri Aug 07, 2009 8:01 pm
by burger2227
At least nobody called him an A$$hole. What happened to your self-description anyhow?