Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy File command looses case in filename 1

Status
Not open for further replies.

beedubau

Programmer
Jan 7, 2003
97
AU
AFAI can see, Copy File command looses case in filename.

I use the same variable for the filename as a web page name and that transfers correctly.

14b4HarryPotterandtheamazingCape.htm
14b4harrypotterandtheamazingcape.jpg


How can I control this. In genealogy people use mixed case a lot.

Regards

Bryan
 
Try Win API CopyFile:

DECLARE INTEGER CopyFile IN KERNEL32 STRING @lpExistingFileName, STRING
@lpNewFileName, INTEGER

lcSrc="c:\temp\xx.txt"+CHR(0)
lcDst="c:\temp\xx1.txt"+CHR(0)
? CopyFile(@lcSrc,@lcDst, 0)
? CopyFile(@lcSrc,@lcDst, 1) && fail if destination file exist
 
The issue is that in Windows, case doesn't matter in file names, while in some other operating systems (including Linux), it does.

Tamar
 
Jan's code doesn't work for me - no copy made. I tried this once before with the same result although I use 'Copyfolder' in my Backups.

This is a serious problem as the Images are copied to a Web Server - I guess the only way is to lower() them all - although the client is against this as they loose readability.

Any other ideas anyone?

Bryan
 
Jan's code does work.
You do not need the Chr(0)'s.
You cannot copy back to the source directory using the same file name. i.e. It will not overwrite the original.

Apart from the above, check if the destination folder exists.

lcSrc="c:\temp\xx.txt"
lcDst="c:\temp\xx1.txt"
DECLARE INTEGER CopyFile IN KERNEL32 STRING @lpExistingFileName, STRING
@lpNewFileName, INTEGER
? CopyFile(@lcSrc,@lcDst, 0)

this should return a 1
 
I don't know what's going wrong - here are the 2 forms of my code

Code:
thispath = (mypictarget)

htmlpath = readpwini(inifile,'read','Paths','HTML')

COPY FILE (thispath)+myownpicture TO (htmlpath)+myownpicture

lcSrc=(thispath)+myownpicture
lcDst=(htmlpath)+myownpicture

DECLARE INTEGER CopyFile IN KERNEL32 STRING @lpExistingFileName, STRING
@lpNewFileName, INTEGER
status =  CopyFile(@lcSrc,@lcDst, 0)

Each path variable has an ending \ so the fullpath looks correct in the debugger.

COPY FILE works

With new code status does not get returned - so I just used the CopyFile directly. Still no copy.

Any ideas?

Bryan
 
Bryan, I am sorry you have troubles with it, but my code works O.K. Imaginecorp is right - chr(0) is not needed. My test prg:
-------
set talk OFF
clear

DECLARE INTEGER CopyFile IN KERNEL32 STRING @lpExistingFileName, STRING @lpNewFileName, INTEGER

lcSrc="c:\usr\tmp\xYz.tXt"
lcDst="c:\usr\tmp\XyZ_nEw.TxT"

IF .not.file(lcSrc)
StrToFile("source file", lcSrc, .F.)
ENDIF
erase (lcDst)

? CopyFile(@lcSrc, @lcDst, 0) && overwrite if exist - should return 1
? CopyFile(@lcSrc, @lcDst, 1) && fail if destination file exist - should return 0
erase (lcDst)
? CopyFile(@lcSrc, @lcDst, 1) && fail if destination file exist - should return 1

RETURN

---------
 
Jan,

old tired eyes were the culprit - the declare line was split on two lines as copied.

<blush>

Bryan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top