Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Working with file names having not English characters
Message
From
17/01/2006 13:13:38
 
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP
Miscellaneous
Thread ID:
01087582
Message ID:
01087637
Views:
16
>The situation is like this:
>There are files coming on CDs that are delivered from various countries. Files need to be copied to the hard drive, and renamed. (Then they should be processed depending on their type).
>The new name should contain the original name, and additional ID or time stamp.
>File FULL file name, not its shortname, should be used.
>
>
>The problem is that when the file name contains not English characters, then the file full name is not recognized or it is not properly recorded.
>The example:
>
>The file having name “_1HelloЗемля.jpg” is visible in Windows Explorer where
>it can be manually copied, renamed as needed, etc.
>But the code does not work:
>
>*Adir(…) function gives “_1Hello?????.jpg” and this name is not recognized
>* with the file() function.
>
>oFSO = CREATEOBJECT("Scripting.FileSystemObject")
>oFile = oFSO.GetFile(getfile()) && gives an error ‘Unknown Com status code’
>
>FOR EACH oitem IN oFSO.GetFolder("c:\").Files
>	WITH oitem
>		IF  "_1"$.name
>			? .name  && returns“_1Hello?????.jpg”
>*     .COpy() method does not work here also, error ‘Unknown Com status code’
>
>		ENDIF
>	endwith
>ENDFOR
>
>
>
>Anyone has ideas or recommendation? Thanks in advance


If you want a correct and professional programmation
you have to use the windows's API.
The whole rest is made for the "young marmots".
DECLARE INTEGER MoveFile IN Win32API ;
   STRING @lpExistingFileName, ;
   STRING @lpNewFileName

oldName = "FILE$$$"
newName = "FILEnew$$$"
STRTOFILE("x",m.oldName)
? FILE(m.oldName),FILE(m.newName)

IF MoveFile(@m.oldName,@m.newName) > 0
   ? "ok"
ELSE
   ? "error"
ENDIF
? FILE(m.oldName),FILE(m.newName)
MoveFileEx is better.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform