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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

COPY TO and COPY FILE don't preserve Case 1

Status
Not open for further replies.

wgcs

Programmer
Mar 31, 2002
2,056
EC
I'm trying to update an old backup routine to VFP9.

I notice that VFP9 still doesn't preserve case on file names when using the "COPY FILE (from) TO (to)" command, and doesn't honor the case you use in "COPY TO DestFileName.DBF".

I've deduced that:
StrToFile( FileToStr('OriginalFile'), 'DestFile.txt' )
DOES work, but only if DestFile.txt doesn't exist yet.

Of course, StrToFile can't work for files over 16MB in size... does anyone have a (simple.. I don't want to use FOPEN and FWRITE... unless you've already written it...) way to copy files and preserve case?

And a way to "COPY TO" and preserve case?

For now, I'm writing routines that will check (using ADIR) if a file is <16MB, then use FIletostr, Delete file, StrToFile to fix the case.

- Bill

Get the best answers to your questions -- See FAQ481-4875.
 
I use the File System Object of the Windows Scripting Host to make backups and that preserves the case of file names:

[TT]
m.fso=Createobject("Scripting.FileSystemObject")
fso.CopyFolder (m.lcDevDir, m.lcBackupDir)
[/TT]

and I've just realised that I'm using CopyFolder not CopyFile. It's worth trying though.

Geoff Franklin
 
have a search for "CopyFile" and find a function declaration in Kernel32 that does preserve the cases of the files.

Rob.
 
Thanks, Geoff, but Windows Scripting Host is out-of-the-question: I want my software to work on all my customers' computers, regardless of whether they are Win95,98,2k or XP, and WSH is too often not available or disabled due to security concerns.

Thanks, Rob... That looks great... MSDN says:
Client: Requires Windows XP, Windows 2000 Professional, Windows NT Workstation, Windows Me, Windows 98, or Windows 95.

so it looks like that's always available. I'm not sure how I overlooked it before (I think I was just searching for Rename functions, and gave up). It seems that if the destination file already exists, the file name case is not 'fixed' to the case specified as a parameter, so even if you copy a file over itself (which works) the case doesn't change.

It doesn't handle renaming a file, though, so if anyone has a solution for the "COPY TO dbffile" idiom in VFP 9, I'd appreciate it.
(For now, I'll probably "COPY TO" a temp file, then use CopyFile to duplicate that in the true final destination.)

- Bill

Get the best answers to your questions -- See FAQ481-4875.
 
I want my software to work on all my customers' computers, regardless of whether they are Win95,98,2k or XP, and WSH is too often not available or disabled due to security concerns.

Good point - wish I'd made it myself<g>. I use WSH here to backup all the project files whenever I open Fox but I do know sites where they've got it turned off.

Geoff Franklin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top