Discussion:
Copy file changes file name case to lower case
(too old to reply)
BT
2004-04-15 22:49:09 UTC
Permalink
Hi All

I have a problem in VFP8 SP1 using the "copy file" command.
I am trying to copy a file to a different folder with exactly the same name
and in the same case.
e.g.

copy file c:\test\MyFile.txt to c:\test2\MyFile.txt

Everything works find except the new file in the folder c:\test2 actually
now has the filename myfile.txt
Thus the name of the file is being converted to lower case, loosing the
capital M and F.
This causes me further problems as I need the name of file to remain in the
same case as the source.
I am running on Windows XP SP 1 with all the latest updates and the disk is
in NTFS format.
I can easily rename the file in explorer to the correct case but need this
to work directly from Foxpro copy file command.

Is this is a bug?
and/or
Is there a workaround?
and/or
Is there an alternative set of code that will do the copy correctly?

Thanks for any help.
John Roberts
Trey Walpole
2004-04-15 23:14:07 UTC
Permalink
You can use the FileSystemObject instead, e.g.

oFSO = CreateObject("Scripting.FileSystemObject")
oFile = oFSO.GetFile("c:\test\MyFile.txt") && must be full path
oFile.Copy("c:\test2\MyFile.txt")
Post by BT
Hi All
I have a problem in VFP8 SP1 using the "copy file" command.
I am trying to copy a file to a different folder with exactly the same name
and in the same case.
e.g.
copy file c:\test\MyFile.txt to c:\test2\MyFile.txt
Everything works find except the new file in the folder c:\test2 actually
now has the filename myfile.txt
Thus the name of the file is being converted to lower case, loosing the
capital M and F.
This causes me further problems as I need the name of file to remain in the
same case as the source.
I am running on Windows XP SP 1 with all the latest updates and the disk is
in NTFS format.
I can easily rename the file in explorer to the correct case but need this
to work directly from Foxpro copy file command.
Is this is a bug?
and/or
Is there a workaround?
and/or
Is there an alternative set of code that will do the copy correctly?
Thanks for any help.
John Roberts
Eric den Doop
2004-04-15 23:17:09 UTC
Permalink
Hello, BT!

Not sure if this is a bug. You can submit it to MS if you like:
http://support.microsoft.com/default.aspx?scid=/support/VFoxPro/Report/Report.asp

I found the following code in my archives. You can use it as a workaround.
<vfp_code>
* move files
* Win32API approach
DECLARE INTEGER MoveFile IN kernel32 STRING lpExistingFileName, STRING
lpNewFileName
MoveFile("d:\setup.exe", "d:\SeTuP.eXe")
* FileSystemObject approach (I think the Scripting host control is actually
making calls to the MoveFile API )
oFSO = CREATEOBJECT("Scripting.FileSystemObject")
oFSO.MoveFile("d:\setup.exe", "d:\SeTuP.eXe")
* copy files
DECLARE INTEGER CopyFile IN kernel32 STRING lpExistingFileName, STRING
lpNewFileName
CopyFile("d:\setup.exe", "c:\SeTuP.eXe")
* FileSystemObject approach (I think the Scripting host control is actually
making calls to the CopyFile API )
oFSO = CREATEOBJECT("Scripting.FileSystemObject")
oFSO.CopyFile("d:\setup.exe", "c:\SeTuP.eXe")
</vfp_code>
--
Eric den Doop
www.foxite.com - The Home Of The Visual FoxPro Experts - Powered By VFP8
Anders
2004-04-16 01:10:03 UTC
Permalink
Windows' filename handling is not case-sensative
Windows' filename handling is not case-sensative
Windows' filename handling is not case-sensative
If you make anything of any real importance depend on case in Windows
filenames it will be an extremly hazardous undertaking.
The case is just beautification, make-up. It has no discriminatory function.
You can try
copy file c:\test\MyFile.txt to c:\test2\*.*
and see if it make any difference.
You can use Windows' API instead:
DECLARE CopyFile IN WinAPI32 STRING, STRING
CopyFile("c:\test\MyFile.txt ", "c:\test2\MyFile.txt")

-Anders
PS The spelling of the API function names in a DECLARE statement is
case-sensative.
-A
Post by BT
Hi All
I have a problem in VFP8 SP1 using the "copy file" command.
I am trying to copy a file to a different folder with exactly the same name
and in the same case.
e.g.
copy file c:\test\MyFile.txt to c:\test2\MyFile.txt
Everything works find except the new file in the folder c:\test2 actually
now has the filename myfile.txt
Thus the name of the file is being converted to lower case, loosing the
capital M and F.
This causes me further problems as I need the name of file to remain in the
same case as the source.
I am running on Windows XP SP 1 with all the latest updates and the disk is
in NTFS format.
I can easily rename the file in explorer to the correct case but need this
to work directly from Foxpro copy file command.
Is this is a bug?
and/or
Is there a workaround?
and/or
Is there an alternative set of code that will do the copy correctly?
Thanks for any help.
John Roberts
John Roberts
2004-04-16 02:31:54 UTC
Permalink
Thank you for all your replies and suggestions.
In response to the various posts:

Eric - I would suggest it is a bug - it is surely not deliberate and if so I
would say that is wrong and should be optional.
I think a posting to the MS bug report site would be appropriate.
However your API solution is obviously the way to go to get around
it.
I changed my reference from BT :) sorry.

Trey - I would never use a scripting object as this is subject to whether
scripting is installed on the target system,
and could possibly be affected by whether script blocking is
installed e.g. Norton Antivirus?
Thanks anyway.

Anders - Just because windows is not case sensitive it does not mean the
rest of the world is not.
I need to have the original case of the filename preserved because I do
multiple file copies then zip them into one file.
This one file then gets ftp'd to Unix server which then unzips the files
but hey they are now case sensitive and invalid!
And all because FoxPro has changed the case the process fails.
Obviously there are more steps and it is more complex process than this,
but this and the original post were/are simplified to demonstrate the
actual problem for the purposes of this post).
Don't be too quick to judge what other people do and deal with the
issue!


This is my second post relating to case sensitivity issues - my other was
many months ago on another issue.
I think that file name case sensitivity can be an important issue when
moving files around the WWW on
servers that are not run by Microsoft software e.g. Unix/Linux.

Thanks for your suggestions
John Roberts
Post by BT
Hi All
I have a problem in VFP8 SP1 using the "copy file" command.
I am trying to copy a file to a different folder with exactly the same name
and in the same case.
e.g.
copy file c:\test\MyFile.txt to c:\test2\MyFile.txt
Everything works find except the new file in the folder c:\test2 actually
now has the filename myfile.txt
Thus the name of the file is being converted to lower case, loosing the
capital M and F.
This causes me further problems as I need the name of file to remain in the
same case as the source.
I am running on Windows XP SP 1 with all the latest updates and the disk is
in NTFS format.
I can easily rename the file in explorer to the correct case but need this
to work directly from Foxpro copy file command.
Is this is a bug?
and/or
Is there a workaround?
and/or
Is there an alternative set of code that will do the copy correctly?
Thanks for any help.
John Roberts
Anders
2004-04-16 06:57:50 UTC
Permalink
"John Roberts" <***@btclick.com> skrev i meddelandet news:c5ngiq$2nc$***@hercules.btinternet.com...

Hi John
There are VFP functions that let you control filename case.
y=FILETOSTR('xx.csv')
?STRTOFILE(y,'xXx.CsV')

n=ADIR(aa,'*.csv','A',1)
For i=1 To n
? aa(i,1)
Next

-Anders
Anders
2004-04-16 07:11:39 UTC
Permalink
Hi John

I understand you have every reason to insist on case control.
There are VFP functions that allow you to read and write filenames with
mixed case.
y=FILETOSTR('xx.csv')
?STRTOFILE(y,'xXx.CsV')

n=ADIR(aa,'*.csv','A',1)
For i=1 To n
? aa(i,1)
Next

-Anders
Villi Bernaroli
2004-04-16 15:12:29 UTC
Permalink
Post by John Roberts
Anders - Just because windows is not case sensitive it
does not mean the rest of the world is not.
I need to have the original case of the filename
preserved because I do multiple file copies then zip them
into one file. This one file then gets ftp'd to Unix
server which then unzips the files but hey they are now
case sensitive and invalid! And all because FoxPro
has changed the case the process fails.
And "all because that Unix software can not recognize
different case-names the process fails".
Comaptibility is an issue of two, never of one.

Vilco

Loading...