Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Working with file names having not English characters
Message
De
18/01/2006 09:39:23
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows XP
Divers
Thread ID:
01087582
Message ID:
01087942
Vues:
11
>>>>>>
>>>>>>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.
>>>>>
>>>>>Thanks, but I do not know the file name in advance. The first problem is how to get the proper end exact file name when reviewing the directory contents.
>>>>
>>>>read the directory with the others window's API.
>>>
>>>Thanks, but with what API? I used FindFirstFile, FindNextFile following the example, say, from *http://www.news2news.com/vfp/?example=236&function=378, and still have "???????" instead of file proper name.
>>
>>It is an UNICODE filename, the binary value is:
>>
>>&& "_1HelloЗемля.jpg"
>>binaryUnicode=0H5F003100480065006C006C006F00170435043C043B044F042E006A0070006700
>>? STRCONV(binaryUnicode,6)
>>
>>
>>VFP don't support UNICODE, then you can manipulate it like a varbinary only
>>
>>this create "_1HelloЗемля.jpg" into the default path,
>>and renames it to "_1HelloЗемля123.jpg"
>>
>>
>>
>>#DEFINE CREATE_ALWAYS                  2
>>#DEFINE FILE_ATTRIBUTE_NORMAL        128
>>
>>* look the W suffix for Wide
>>    DECLARE INTEGER MoveFileW IN kernel32;
>>        STRING lpExistingFileName,;
>>        STRING lpNewFileName
>>
>>    DECLARE INTEGER CreateFileW IN kernel32;
>>        STRING  lpFileName,;
>>        INTEGER dwDesiredAccess,;
>>        INTEGER dwShareMode,;
>>        INTEGER lpSecurityAttributes,;
>>        INTEGER dwCreationDisposition,;
>>        INTEGER dwFlagsAndAttributes,;
>>        INTEGER hTemplateFile
>>
>>	DECLARE INTEGER CloseHandle IN kernel32 INTEGER hObject
>>
>>CLEAR
>>dbyteFileName =  0h+STRCONV(STRCONV("\\?\"+ADDBS(_VFP.DefaultFilePath),1),5);
>>                +0H5F003100480065006C006C006F00170435043C043B044F042E006A0070006700
>>
>>hFile = CreateFileW(m.dbyteFileName+0H0, 0, 0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0)
>>
>>? "File handle returned:", hFile
>>= CloseHandle (hFile)
>>
>>? GETFILE("JPG")
>>* RENAME TO ...name123.jpg
>>=MoveFileW(m.dbyteFileName+ 0h0 ;
>>          ,STUFF(m.dbyteFileName,LEN(dbyteFileName)+1-4*2,0,STRCONV(STRCONV("123",1),5))+0h0)
>>? GETFILE("JPG")
>>
>>
>>use FindFirstFileW, FindNextFile and MoveFileW
>>
>>Hi
>
>Viva Italy!
>
>Any chance to get it work in VFP8 or VFP7?

when you goes out of the support of an application,
the master solution is to use raw binary data.
In VFP8 and VFP7 string should work however because
VFP should not apply code page translation.
In VFP8 you can see the string hex with STRCONV(,15).
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform