View Full Version : Possible to copy from CD?
I've been working on a program to copy several files from a CD into My Documents. There is no error, but the files won't copy. Is there something special you have to do when you copy from one drive to another? Right now I'm just using:
FILE_COPY("D:\copy.zip", "C:\Program Files\install\copy.zip")
Hi nrodes, the following script works fine for me. I was able to copy a document from a CD to my desktop using it.
uses "FILE"
uses "CONSOLE"
dim error
error = file_copy("E:\Documents\MY_PDF.pdf", "C:\Users\Matthew\Desktop\MY_PDF.pdf")
console_cls
console_printat (error, 1, 1)
console_waitkey
Michael Clease
10-02-2009, 15:43
Nrodes are you using Vista?
ErosOlmi
10-02-2009, 17:04
When using special folders, be sure to use dedicated function OS_GetSpecialFolder(CLSID) (http://www.thinbasic.com/public/products/thinBasic/help/html/os_getspecialfolder.htm)
Be sure to indicate in CLSID (http://www.thinbasic.com/public/products/thinBasic/help/html/osequates.htm) one of the supported equates (constants)
You cannot be sure where special folders are located. They can change from computer to computer or by OS version to OS version.
Ciao
Eros
Nrodes are you using Vista?
No, I use XP Pro
ErosOlmi
12-02-2009, 15:37
nrodes,
because here it seems all is working fine with FILE_Copy function, I need to ask just few questions:
did you solved the problem or still there ?
Sure 100% that D: exists and CD is loaded at the time you execute the command ?
How big is you file ?
What are the file attributes: system/hidden/readonly ?
Does destination path "C:\Program Files\install\" alredy exist in your computer?
Sorry to bother you but some more info are needed.
Thanks
Eros
nrodes,
because here it seems all is working fine with FILE_Copy function, I need to ask just few questions:
did you solved the problem or still there ?
Sure 100% that D: exists and CD is loaded at the time you execute the command ?
How big is you file ?
What are the file attributes: system/hidden/readonly ?
Does destination path "C:\Program Files\install\" alredy exist in your computer?
Sorry to bother you but some more info are needed.
Thanks
Eros
I'm sure D: exists
My file is about 1.5 GB
File is hidden
I'm sure directory doesn't exist
ErosOlmi
13-02-2009, 07:59
Ok thanks.
I never tested a 1.5Gb copy with thinBasic but up to 2Gb it should not be a problem.
Instead it is a problem if destination path does not exist. So "C:\Program Files\install\" must be checked before starting to copy a file in there.
The following is a possible solution:
uses "file"
uses "OS"
uses "console"
dim SourcePath as string = "D:\"
'---Here it is better to use os_getspecialfolder function instaed of fixed path
'---because "Program files" is not fixed and can be located in any place
'dim DestinationPath as string = "C:\Program Files\install\"
dim DestinationPath as string = os_getspecialfolder(%CSIDL_PROGRAM_FILES) & "install\"
dim FileToCopy as string = "copy.zip"
printl "Started " & time$
'---Check if directory exists and if not create the full path with all intermediated paths
'---DIR_MakeAll has power
if dir_exists(DestinationPath) = %FALSE then
printl "Destination dir does not exist."
printl "Making full Destination path: " & DestinationPath
DIR_MakeAll(DestinationPath)
end if
'---Check if file exists
if file_exists(SourcePath & FileToCopy) then
printl "Copying file " & SourcePath & FileToCopy
printl "File size " & file_size(SourcePath & FileToCopy)
file_copy(SourcePath & FileToCopy, DestinationPath & FileToCopy)
else
printl "File " & SourcePath & FileToCopy & " does not exist."
end if
'---Finished
printl "Finished " & time$
waitkey